-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsample.php
More file actions
41 lines (36 loc) · 795 Bytes
/
Copy pathsample.php
File metadata and controls
41 lines (36 loc) · 795 Bytes
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
<?php
session_start();
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "new_test";
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$name=$_POST["name"];
$email=$_POST["email"];
$password=$_POST["password"];
switch($_POST["gender"])
{
case 'male':
$gender=0;
break;
case 'female':
$gender=1;
break;
case 'other':
$gender=2;
break;
}
// Create connection
$sql = "INSERT INTO user_data (Name, Email, Password,Gender)
VALUES ('$name','$email','$password', '$gender');";
if ($conn->query($sql) === TRUE) {
echo "New record created successfully";
} else {
echo "Error: " . $sql . "<br>" . $conn->error;
}
$conn->close();
?>