-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
60 lines (58 loc) · 2.06 KB
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<?php
$insert=false;
if(isset($_POST['name'])){
$server="localhost";
$user="root";
$password="";
$con=mysqli_connect($server,$user,$password);
if(!$con){
die("The connection to this database failed");
}
$name=$_POST['name'];
$age=$_POST['age'];
$gender=$_POST['gender'];
$email=$_POST['email'];
$phone=$_POST['phone'];
$other=$_POST['other'];
$sql="INSERT INTO `trip_form`.`trip` (`name`, `age`, `gender`, `email`, `phone`, `other`, `dt`) VALUES ('$name', '$age', '$gender', '$email', '$phone', '$other', current_timestamp())";
echo "Success connecting to the db";
if($con->query($sql)==true){
// echo "Successfully inserted";
$insert=true;
}
else{
echo "ERROR: $sql <br> $con->error";
}
$con->close();
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Welcome to Travel Form</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div class="container">
<h1>Welcome to ITM University Travel Form</h1>
<p>Enter your details to participate</p>
<?php
if($insert==true){
echo "<h3 class='submit-msg'>Thankyou for submitting</h3>";
}
?>
<form action="index.php" method="post">
<input type="text" name="name" id="name" placeholder="Enter your name">
<input type="text" name="age" id="age" placeholder="Enter your age">
<input type="text" name="gender" id="gender" placeholder="Enter your gender">
<input type="email" name="email" id="email" placeholder="Enter your Email">
<input type="text" name="phone" id="phone" placeholder="Enter your Phone">
<textarea name="other" id="other" cols="30" rows="10">Enter any other info here</textarea>
<button class="btn">Submit </button>
</form>
</div>
<script src="index.js"></script>
</body>
</html>