You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
49 lines
1.5 KiB
49 lines
1.5 KiB
6 months ago
|
<?php
|
||
|
$servername = "localhost";
|
||
|
$username = "root"; // Default XAMPP username
|
||
|
$password = ""; // Default XAMPP password (usually empty)
|
||
|
$dbname = "user";
|
||
|
|
||
|
// Create connection
|
||
|
$conn = new mysqli($servername, $username, $password, $dbname);
|
||
|
|
||
|
// Check connection
|
||
|
if ($conn->connect_error) {
|
||
|
die("Connection failed: " . $conn->connect_error);
|
||
|
}
|
||
|
|
||
|
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
|
||
|
$username = isset($_POST['username']) ? $_POST['username'] : '';
|
||
|
$email = isset($_POST['email']) ? $_POST['email'] : '';
|
||
|
$dob = isset($_POST['dob']) ? $_POST['dob'] : '';
|
||
|
$password = isset($_POST['password']) ? $_POST['password'] : '';
|
||
|
$country = isset($_POST['country']) ? $_POST['country'] : '';
|
||
|
$profession = isset($_POST['profession']) ? $_POST['profession'] : '';
|
||
|
$gender = isset($_POST['gender']) ? $_POST['gender'] : '';
|
||
|
// Capture form data
|
||
|
$username = $_POST['username'];
|
||
|
$email = $_POST['email'];
|
||
|
$dob = $_POST['dob'];
|
||
|
$password = $_POST['password'];
|
||
|
$country = $_POST['country'];
|
||
|
$profession = $_POST['profession'];
|
||
|
$gender = $_POST['gender'];
|
||
|
|
||
|
// Insert data into the database
|
||
|
$sql = "INSERT INTO registration (username, email, dob, password, country, profession, gender)
|
||
|
VALUES ('$username', '$email', '$dob', '$password', '$country', '$profession', '$gender')";
|
||
|
|
||
|
if ($conn->query($sql) === TRUE) {
|
||
|
}
|
||
|
else {
|
||
|
echo "Error: " . $sql . "<br>" . $conn->error;
|
||
|
}
|
||
|
}
|
||
|
$conn->close();
|
||
|
?>
|
||
|
<html>
|
||
|
<body>
|
||
|
<P ><a href="login.php">Continue to Login</a></P>
|
||
|
</body>
|
||
|
</html>
|