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
your source for video gaming entertainment
<?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:
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]