I setup this signup form for my website. People enter their username, email and password and then it uses php to add it to my database. But I keep getting this error when I run my code. My html file is on my AWS server as well as this PHP file, so I believe there must be an error in my code. I am still very new to PHP.
HTML:
<form method="get" action="signup_form.php">
<input style="width: 300px; display: block; margin-left: auto; margin-right: auto;" type="text" name="signup_name" placeholder="Screen Name">
<br>
<input style="width: 300px; display: block; margin-left: auto; margin-right: auto;" type="text" name="signup_mail" placeholder="Your E-mail">
<br>
<input style="width: 300px; display: block; margin-left: auto; margin-right: auto;" type="password" name="signup_password" id = "password" placeholder="Create Password" required>
<br>
<input style="width: 300px; display: block; margin-left: auto; margin-right: auto;" type="password" name="confirm_password" id = "confirm_password" placeholder="Repeat Password" required>
<br>
<br>
<button onclick="validatePassword()" class="button" style="display: block; margin-left: auto; margin-right: auto;" type="submit" name="submit_login">
SUBMIT
</button>
</form>
and here is my PHP code:
<?php
$signup_name = filter_input(INPUT_GET, 'signup_name');
$signup_mail = filter_input(INPUT_GET, 'signup_mail');
$signup_password = filter_input(INPUT_GET, 'signup_password');
if (!empty($signup_name)){
if (!empty($signup_mail)){
$host = "wildwea.......onaws.com";
$dbusername = "a....in";
$dbpassword = ".Bi....4.";
$dbname = "innodb";
// Create connection
$conn = new mysqli ($host, $dbusername, $dbpassword, $dbname);
if (mysqli_connect_error()){
die('Connect Error ('. mysqli_connect_errno() .') '
. mysqli_connect_error());
}
else{
$sql = "SELECT EXISTS (SELECT 1 FROM Users WHERE Email = $signup_mail);"
if ($sql = 0){
$sql = "INSERT INTO Users (Username, Email, Pword)
values ('$signup_name', '$signup_mail',md5('$signup_password'))";
if ($conn->query($sql)){
echo "New record is inserted sucessfully";
}
else{
echo "Error: ". $sql ."
". $conn->error;
}
$conn->close();
} else {
echo "User already in database";
}
}
}
else{
echo "Password should not be empty";
die();
}
}
else{
echo "Username should not be empty";
die();
}
?>
If you want to see the error here is the link to the sign up page: http://thewildwear.com/signup.html