I followed your tutorial here about user registration using PHP and MySQL here:
https://youtu.be/qjwc8ScTHnY
However, Im getting these errors:
Warning: Undefined array key "username" in C:\xampp\htdocs\Sublime\Web1\server.php on line 17
Warning: Undefined array key "email" in C:\xampp\htdocs\Sublime\Web1\server.php on line 18
Warning: Undefined array key "password" in C:\xampp\htdocs\Sublime\Web1\server.php on line 19
Warning: Undefined array key "confirmpassword" in C:\xampp\htdocs\Sublime\Web1\server.php on line 20
This are those line:
$username = mysqli_real_escape_string($db, $_POST['username']);
$email = mysqli_real_escape_string($db, $_POST['email']);
$password = mysqli_real_escape_string($db, $_POST['password']);
$confirmpassword = mysqli_real_escape_string($db, $_POST['confirmpassword']);
I did a work around by doing this:
if (isset($_POST['username']) || isset($_POST['email']) || isset($_POST['password']) || isset($_POST['confirmpassword'])) {
$username = mysqli_real_escape_string($db, $_POST['username']);
$email = mysqli_real_escape_string($db, $_POST['email']);
$password = mysqli_real_escape_string($db, $_POST['password']);
$confirmpassword = mysqli_real_escape_string($db, $_POST['confirmpassword']);
}
But now Im getting undefined variable at line 30 which are $password and $confirmpassword which is the line:
if ($password != $confirmpassword) {array_push($errors, "Password must be the same");};
Please help! And why am I getting these errors? Thanks!