-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
109 lines (80 loc) · 2.66 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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
<?php
include('config/constants.php');
?>
<html>
<head>
<title>Registration Form</title>
<link rel="stylesheet" href="style.css">
<script src='https://www.google.com/recaptcha/api.js'></script>
</head>
<body>
<div class="registration-form">
<h2>Fill the Form</h2>
<form method="POST" action="">
<div>
<label>Name:</label>
<input type="text" name="name" placeholder="Enter your Name">
</div>
<div>
<label>Email:</label>
<input type="email" name="email" placeholder="Enter your Email">
</div>
<div>
<label>Date Of Birth:</label>
<input type="date" name="date" placeholder="Enter your DOB" required>
</div>
<div>
<label>About yourself:</label>
<textarea name="about_yourself" placeholder="aboutyourself"></textarea>
</div>
<div class="g-recaptcha" data-sitekey="6LeozooUAAAAABzm4nBRhxbcqapbiLACfaD1Y1F2">
</div>
<input type="submit" name="submit" value="submit">
</form>
<div class="status">
</div>
<?php
if(isset($_POST['submit']))
{
$secretKey = "6LfKjAAdAAAAAEdXBNUrpzL46m78hRsurjVyAnb5"
;
$url = "https://www.google.com/recaptcha/api/siteverify?
secret=$secretKey";
}
?>
</div>
</body>
</html>
<?php
//Connect Database
$conn = mysqli_connect(LOCALHOST, DB_USERNAME, DB_PASSWORD) or die(mysqli_error());
//Select Database
$db_select = mysqli_select_db($conn, DB_NAME) or die(mysqli_error());
//Create SQL Query to Get DAta from Databse
$sql = "SELECT * FROM tbl_form";
//Execute Query
$res = mysqli_query($conn, $sql);
//Check whether the SAVE button is clicked or not
if(isset($_POST['submit']))
{
//echo "Button Clicked";
//Get all the Values from Form
$name = $_POST['name'];
$email = $_POST['email'];
$date = $_POST['date'];
$about_yourself = $_POST['about_yourself'];
//Connect Database
$conn2 = mysqli_connect(LOCALHOST, DB_USERNAME, DB_PASSWORD) or die(mysqli_error());
//SElect Database
$db_select2 = mysqli_select_db($conn2, DB_NAME) or die(mysqli_error());
//CReate SQL Query to INSERT DATA into DAtabase
$sql2 = "INSERT INTO tbl_form SET
name = '$name',
email = '$email',
date = '$date',
about_yourself = '$about_yourself'
";
//Execute Query
$res2 = mysqli_query($conn2, $sql2);
}
?>