I’ve been trying for the past day to setup this register system and the INSERT just wont work.
<?php
$con = mysqli_connect('localhost', 'root', 'root', 'creators');
if(mysqli_connect_errno())
{
echo("1"); //error code #1 = connection failed
exit();
};
$username = $_POST["username"];
$password = $_POST["password"];
$email = $_POST["email"];
$discord = $_POST["discord"];
$namecheckquery = "SELECT username FROM userprofiles WHERE username='" . $username . "';";
$namecheck = mysqli_query($con, $namecheckquery) or die("2: Namecheck query failed"); //error code #2 - namecheck query failed
if(mysqli_num_rows($namecheck) > 0){
echo("3: Name Already Exists");
exit();
};
$emailcheckquery = "SELECT email FROM userprofiles WHERE email='" . $email . "';";
$emailcheck = mysqli_query($con, $emailcheckquery) or die("5: emailCheck Query Failed"); //error code #2 - namecheck query failed
if(mysqli_num_rows($emailcheck) > 0){
echo("6: Name Already Exists");
exit();
};
$salt = "\$\5rounds=50000\$" . "stickyhoney" . $username . "\$";
$hash = crypt($password, $salt);
mysqli_query($con, "INSERT INTO userprofiles (username, hash, salt, email, discord) VALUES ('$username' , '$hash' , '$salt' , '$email' , '$discord')") or die("4: Insert Player Query Failed"); //this line has the issues and I dont know why
echo("0");
?>