Possible Duplicate:
Form Submits to white page?
So on my page, index.php, there is a registration form. The form checks for errors, and if theres errors, it doesn't do the query, however, if there is no errors, it is supposed to submit the query.
When a user types in all their info, and presses Register, the form submits correctly and displays all the errors that they did.
HOWEVER, if there is NO errors, the form submits to a white page, and the query is not executed.
The form uses method="POST", just a heads up.. Here's the PHP.
$errors=array();
if (isset($_POST['register'])) {
if ($_POST['register']) {
$rUsername=$_POST['usernamei'];
$rPassword=$_POST['passwordi'];
$rConfirm=$_POST['confirm'];
$rEmail=$_POST['email'];
$rProvider=$_POST['provider'];
$rFirst=$_POST['firstname'];
$rLast=$_POST['lastname'];
$rRefer=$_POST['refer'];
$allow=array('_', '-', '.');
include 'mysqlcon.php';
if (!$rUsername) {
array_push($errors, 'You must enter a username!');
} else {
if (!ctype_alnum($rUsername)) {
array_push($errors, 'Your username must be alphanumeric!');
} else {
$checkexist=(mysql_numrows(mysql_query(
"SELECT * FROM users WHERE username='".$rUsername."'")))
or die(mysql_error());
if (!$checkexist==0) {
array_push($errors, 'This username is taken!');
}
}
if (strlen($rUsername)>15) {
array_push($errors, 'Your username is greater than 15 characters long!');
}
}
if (!$rPassword) {
array_push($errors, 'You must enter a password');
} else {
if (!ctype_alnum($rPassword)) {
array_push($errors, 'Sorry, but passwords must be alphanumeric!');
}
}
if (!$rConfirm) {
array_push($errors, 'You must confirm your password!');
} else {
if (!$rConfirm==$rPassword) {
array_push($errors, 'Your password did not match the confirmation!');
}
}
if (!$rEmail) {
array_push($errors, 'You did not enter an email!');
} else {
if (!ctype_alnum(str_ireplace($allow, '', $rEmail))) {
array_push($errors, 'Your email contained some invalid characters!');
}
}
if (!$rProvider) {
array_push($errors, 'You did not enter an email!');
} else {
if (!ctype_alnum(str_ireplace($allow, '', $rProvider))) {
array_push($errors, 'Your email provider contained some invalid characters!');
}
}
if (!$rFirst) {
array_push($errors, 'You did not enter your first name!');
} else {
if (!ctype_alnum(str_ireplace($allow, '', $rFirst))) {
array_push($errors, 'Your first name can only contain alphanumeric characters!');
}
}
if (!$rLast) {
array_push($errors, 'You did not enter your last name!');
} else {
if (!ctype_alnum(str_ireplace($allow, '', $rLast))) {
array_push($errors, 'Your first name can only contain alphanumeric characters!');
}
}
if ($rRefer) {
if (!ctype_alnum(str_ireplace($allow, '', $rRefer))) {
array_push($errors, 'Your friend\'s name can only be alphanumeric!');
}
}
}
}
if (empty($errors)) {
$isError="1";
} else {
$isError="2";
}
20 minutes later
Just found out that it submits a query with blank fields when a user goes to index.php.. I'm so stressed out right now. :(
Edit
Just turned on error reporting- no errors.
Edit II
This is the query code:
if ($isError=="1") {
$userip=$_SERVER['REMOTE_ADDR'];
$today=date('Y').'/'.date('m').'/'.date('d');
$temail=$rEmail.'@'.$rProvider;
$newuser = "INSERT INTO users (username, password, firstname, lastname, email, date, ip)
VALUES ('$rUsername', '$rPassword', '$rFirst', '$rLast', '$temail', '$today', '$userip')";
mysql_query($newuser);
}
Edit III* Alright, so I just experimented a little, and it seems as if any code below the if statement for checking if $_POST['register'] is there DOES NOT EXECUTE.. However, when there is user registration errors like 'You must enter a username!', code executes..