I have made 3 pages: form, database connection and registration page. I am not getting any error but when I register a new user on the form page, it does not apear on phpmyadmin dashboard.
Please help me
What should I do?
My form is here:
<!DOCTYPE html> <html> <head>
<title></title> <meta charset="utf-8"> </head> <body> <div
style="background-color: #222; color: #fff; height: 50px; width:
100%;"></div> <style type="text/css"> body{ background-color:
#e1e1e1; } form{ margin-top: 20px; background-color: #fff;
} form input{ padding: 4px; }
button{ width: 100px; height: 35px; background-color: #222;
color: #fff; margin-top: 10px; border: 2px dotted; }
</style> <form action="register.php" method="POST"> Forname:<br> <input type="text" name="first" id="first"
size="50"><br> Aftername:<br> <input type="text" name="last"
size="50"><br> E-post:<br> <input type="text" name="email"
size="50"><br> Username:<br> <input type="text" name="username"
size="50"><br> Password:<br> <input type="password" name="password"
size="50"><br> <button type="submit" name="submit"
id="btn-submit">Sign Up</button>
</form> </body> </html>
My database connection:
<?php $conn =
mysqli_connect("127.0.0.1","root", "","test1"); if (!$conn) {
die("You can't connect to the database");
} else echo "Your registration is succesed";
?>
My registration page:
<?php require 'db.php'; ?> <?php
if(isset($_POST['submit'])){ session_start(); $hostname =
"127.0.0.1"; $username = "root"; $password = ""; $database = "login";
$first = $_POST['first']; $last = $_POST['last']; $email =
$_POST['email']; $username = $_POST['username']; $password =
$_POST['password'];
$sql = $conn->query("INSERT INTO
users(first,last,email,username,password)values('{$first}','{$last}','{$email}','{$password}')");
header('Location: login.php'); }
?>