-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
92 lines (77 loc) · 2.79 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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
<?php
$insert = false;
if(isset($_POST['name'])){
// Connection variable
$server = "localhost";
$username = "root";
$password = "";
// make connection with database
$con = mysqli_connect($server, $username, $password);
// check for connection success
if(!$con){
die("connection to this database failed due to" .
mysqli_connect_error());
}
//echo "Success connecting to the db"
// Collect data from the user
$name = $_POST['name'];
$age = $_POST['age'];
$gender = $_POST['gender'];
$email = $_POST['email'];
$phone = $_POST['phone'];
$other = $_POST['other'];
$sql = "INSERT INTO `trip`. `trip` (`name`, `age`, `gender`, `email`,`phone`, `other`, `dt`)
VALUES ('$name', '$age', '$gender', '$email',
'$phone', '$other', current_timestamp());";
//echo $sql;
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">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link
href="https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,
100;0,300;0,400;0,500;0,700;0,900;1,100;1,300;1,400;1,500;1,700;1,
900&family=Sriracha&display=swap"
rel="stylesheet">
</head>
<body>
<img class="bg" src="bg.jpg" alt="bgimg">
<div class="container">
<h3>Welcome to IIT Kharagpur US Trip form</h3>
<p>Enter your details and submit this form to
confirm your participation in the trip</p>
<?php
if($insert == true) {
echo "<p class='submitMsg'>Thanks for submitting your form. We are happy to
see you joining us for the US trip.</p>";
}
?>
<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="phone" name="phone" id="phone" placeholder="Enter your phone">
<textarea name="other" id="desc" placeholder="Enter any other information"
cols="30" rows="10"></textarea>
<button class="btn">Submit</button>
</form>
</div>
<script src="index.js"></script>
</body>
</html>