Problem with register script

I created this registration script from scratch and whenever I register it takes me back to the register page and does nothing.

[code]<?php
require(‘includes/connect.inc.php’);
?>

xUltimate: Beta

xUltimate

your source for video gaming entertainment

Register

 
<?php if($_GET['err'] != ""){ if($_GET['err'] == 1){ echo "Username required."; }elseif($_GET['err'] == 2){ echo "Password required."; }elseif($_GET['err'] == 3){ echo "Password required."; }elseif($_GET['err'] == 4){ echo "Passwords do not match."; }elseif($_GET['err'] == 5){ echo "E-mail required."; }elseif($_GET['err'] == 6){ echo "Username already exists."; }elseif($_GET['err'] == 7){ echo "Email is already in-use."; } } ?> Username:
Password:
Confirm Password:
E-mail:
 
  •  
  • What we are all about

    xUltimate is a online community where we provide almost anything in video gaming entertainment.

  • <?php require('includes/menu.php'); ?>
 

Copyright © 2011 xUltimate. All rights reserved.

<?php if($_POST['submitted'] == 1){ if($_POST['username'] == ""){ header("Location: register.php?err=1"); return 0; } if($_POST['password'] == ""){ header("Location: register.php?err=2"); return 0; } if($_POST['cpassword'] == ""){ header("Location: register.php?err=3"); return 0; } if($_POST['password'] != $_POST['cpassword']){ header("Location: register.php?err=4"); return 0; } if($_POST['email'] == ""){ header("Location: register.php?err=5"); return 0; } $ucheck = mysql_query("SELECT * FROM accounts WHERE username='".$_POST['username']."'"); if(mysql_num_rows($ucheck) > 0){ header("Location: register.php?err=6"); return 0; } $echeck = mysql_query("SELECT * FROM accounts WHERE email='".$_POST['email']."'"); if(mysql_num_rows($echeck) > 0){ header("Location: register.php?err=7"); return 0; } $result = mysql_query("INSERT INTO accounts(username, password, email) VALUES('".$_POST['username']."', '".md5($_POST['password'])."', '".$_POST['email']."'"); if($result){ header("Location: login.php?err=1"); } } ?>[/code]

Just the php:

[code]<?php
if($_GET[‘err’] != “”){
if($_GET[‘err’] == 1){
echo “Username required.”;
}elseif($_GET[‘err’] == 2){
echo “Password required.”;
}elseif($_GET[‘err’] == 3){
echo “Password required.”;
}elseif($_GET[‘err’] == 4){
echo “Passwords do not match.”;
}elseif($_GET[‘err’] == 5){
echo “E-mail required.”;
}elseif($_GET[‘err’] == 6){
echo “Username already exists.”;
}elseif($_GET[‘err’] == 7){
echo “Email is already in-use.”;
}
}
?>

<?php if($_POST['submitted'] == 1){ if($_POST['username'] == ""){ header("Location: register.php?err=1"); return 0; } if($_POST['password'] == ""){ header("Location: register.php?err=2"); return 0; } if($_POST['cpassword'] == ""){ header("Location: register.php?err=3"); return 0; } if($_POST['password'] != $_POST['cpassword']){ header("Location: register.php?err=4"); return 0; } if($_POST['email'] == ""){ header("Location: register.php?err=5"); return 0; } $ucheck = mysql_query("SELECT * FROM accounts WHERE username='".$_POST['username']."'"); if(mysql_num_rows($ucheck) > 0){ header("Location: register.php?err=6"); return 0; } $echeck = mysql_query("SELECT * FROM accounts WHERE email='".$_POST['email']."'"); if(mysql_num_rows($echeck) > 0){ header("Location: register.php?err=7"); return 0; } $result = mysql_query("INSERT INTO accounts(username, password, email) VALUES('".$_POST['username']."', '".md5($_POST['password'])."', '".$_POST['email']."'"); if($result){ header("Location: login.php?err=1"); } } ?>[/code]

I’ve seperated the PHP code from the HTML page and it works until the INSERT INTO statement, I receive the following error

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 '' at line 1

Here’s my PHP Code: <?php require('includes/connect.inc.php'); if($_POST['submitted'] == 1){ if($_POST['username'] != ""){ if($_POST['password'] != ""){ if($_POST['cpassword'] != ""){ if($_POST['password'] == $_POST['cpassword']){ if($_POST['email'] != ""){ $username = $_POST['username']; $password = md5($_POST['password']); $email = $_POST['email']; $ucheck = mysql_query("SELECT * FROM accounts WHERE username='$username'"); if(mysql_num_rows($ucheck) == 0){ $echeck = mysql_query("SELECT * FROM accounts WHERE email='$email'"); if(mysql_num_rows($echeck) == 0){ $result = mysql_query("INSERT INTO accounts(username, password, email) VALUES('$username', '$password', '$email'") or die(mysql_error()); /*if($result){ header("Location: login.php?err=1"); }else{ header("Location: register.php?err=8"); }*/ }else{ header("Location: register.php?err=7"); } }else{ header("Location: register.php?err=6"); } }else{ header("Location: register.php?err=5"); } }else{ header("Location: register.php?err=4"); } }else{ header("Location: register.php?err=3"); } }else{ header("Location: register.php?err=2"); } }else{ header("Location: register.php?err=1"); } }else{ header("Location: register.php"); } ?>

Sponsor our Newsletter | Privacy Policy | Terms of Service