Hello.
Look at this file please:
register.php
<?php
$servername = "localhost";
$dbname = "mydbname";
$dbusername = "mydbusername";
$dbpassword = "mydbpassword";
try {
$conn = new PDO("mysql:host=$servername;dbname=$dbname", $dbusername, $dbpassword);
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$sql = "INSERT INTO Users (Username, Password)
VALUES ('$username', '$password')";
$conn->exec($sql);
}
catch(PDOException $e)
{
echo $sql . "<br>" . $e->getMessage();
}
$conn = null;
?>
<html>
<head>
<title>Register Page</title>
</head>
<body>
<form method="post">
Your Username: <input type="text" name="username"><br>
Your Password: <input type="text" name="password"><br>
<input type="submit" value="submit">
</form>
</body>
Why it can't send the username and password that gets from those two fields to the table? I checked the table, the ID was incresed everytime but the fileds of username and password were empty on the table.