user6543208 user6543208 - 1 month ago 6
MySQL Question

Data is not inserting on the database Game resgistration

So im making a web game app my problem is my

register.php
is not inserting users in the database please need help by the way im just a beginner in PHP Thanks

Here is the Code:

<?php
require_once('mysql_conn.php');
$Username = mysql_real_escape_string($_POST['Username']);
$Password = md5(mysql_real_escape_string($_POST['Password']));
$Email = mysql_real_escape_string($_POST['Email']);

$query_check ="SELECT user_name FROM account_info WHERE user_name = '$Username'";
$retval_check = mysql_query( $query_check, $conn );

if( $Username == "" || $Password == "" || $Email == "" ){
echo"Please fill the field";
} else{
if(mysql_num_rows($retval_check)){
echo"Username Already Taken";
} else {
$query = "INSERT INTO account_info(user_name,user_passemail) VALUES ('$Username','$Password','$Email');";
$retval = mysql_query( $query, $conn );

echo "<script>";
echo "alert('Thank you for registering Enjoy the game !')";
echo "</script>";

echo "<script>";
echo 'location.href = "menu.html";';
echo "</script>";
}
}

mysql_close($conn);

?>

Answer

Change:

$query = "INSERT INTO account_info(user_name,user_passemail) VALUES ('$Username','$Password','$Email');";

To:

$query = "INSERT INTO account_info(user_name,user_pass,email) VALUES ('$Username','$Password','$Email');";

You forgot to add a comma ","