Im watching tutorials on how to program in php. I got to the point to where i create a registration page but when i go to register i get this error
Notice: Undefined index: password in C:\xampp\htdocs\game\register.php on line 13
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''user' WHERE 'username' ='knjj2008'' at line 1
here is the code
<?php
include("functions.php");
connect();
?>
<?php
if(isset($_POST['register'])){
$username = protect($_POST['username']);
$password = protect($_POST['password']);
$email = protect($_POST['email']);
if(strlen($username) > 20){
echo "Username must be less than 20 characters!";
}elseif(strlen($email) > 100){
echo "E-mail must be less than 100 characters!";
}else{
$register1 = mysql_query("SELECT 'id' FROM 'user' WHERE 'username' ='$username'") or die(mysql_error());
$register2 = mysql_query("SELECT 'id' FROM 'user' WHERE 'email' ='$email'") or die(mysql_error());
if(mysql_num_rows($register1) > 0){
echo "That username is already in use!";
}elseif(mysql_num_rows($register2) > 0){
echo "That e-mail adress is already in use!";
}else{
$ins1 = mysql_query("INSERT INTO 'stats' ('gold','attack','defense','food') VALUES (100,10,10,100)") or die(mysql_error());
$ins2 = mysql_query("INSERT INTO 'unit' ('worker','farmer','warrior','defender') VALUES (5,5,0,0)") or die(mysql_error());
$ins3 = mysql_query("INSERT INTO 'user' ('username','password','email') VALUES ('$username','".md5($password)."','$email')") or die
(mysql_error());
$ins4 = mysql_query("INSERT INTO 'weapon' ('sword',shield') VALUES (0,0)") or die(mysql_error());
echo "You have registered!";
}
}
}
?>
Register
<br />
<form action="register.php" method="POST">
Username: <input type="text" name="username"/><br /><br />
Password: <input type="password" name="username"/><br /><br />
E-mail: <input type="text" name="email"/><br /><br />
<input type="submit" name="register" value="Register"/>
</form>