Hey
Im having this problem, im sure theres a simple solution, but i cant seem to see it :D
The code bellow is part of a regestration form validation. Basicly when i ask the database if anyone else exists with the same username, password or email address - it works
BUT
Only if it returns 1 or more rows!
If no-one else exists with the username ect. it returns my error message (couldnt check rows).
<form method="post" name="details">
<b class="form_title">First Name:
</b><input type="text" name="first_name" class="form_box" />
<br />
<b class="form_title">Last Name:
</b><input type="text" name="last_name" class="form_box"/>
<br />
<b class="form_title">Age:
</b><input type="text" name="age" class="form_box" />
<br />
<b class="form_title" >Email:
</b><input type="text" name="email" class="form_box" />
<br />
<b class="form_title" >Phone:
</b><input type="text" name="phone" class="form_box" />
<br />
<b class="form_title">Address:
</b><textarea name="address" class="form_box"></textarea>
<br />
<b class="form_title" >Username:
</b><input type="text" name="username" class="form_box"/>
<br />
<b class="form_title" >Password:
</b><input type="password" name="password1" class="password"/>
<br />
<b class="form_title" >Repeat:
</b><input type="password" name="password2" class="password" />
<br />
<b class="form_title">I accept the terms of using this website
</b> <input type="checkbox" name="terms" class="form_box" />
<br />
<input type="submit" value="Regester Me"/>
</form>
<?php
$priv = "LIMITED";
$first_name = $_REQUEST["first_name"];
$last_name = $_REQUEST["last_name"];
$age = $_REQUEST["age"];
$email = $_REQUEST["email"];
$phone = $_REQUEST["phone"];
$address = $_REQUEST["address"];
$username = $_REQUEST["username"];
$pass1 = $_REQUEST["password1"];
$pass2 = $_REQUEST["password2"];
$terms = $_REQUEST["terms"];
if (empty($first_name) || empty($last_name) || empty($age) ||
empty($email) || empty($phone) || empty($address) || empty($username) || empty($pass1) || empty($pass2)) {
$error = "You Must Fill In All The Boxs.";
}
elseif ($pass1 != $pass2) {
$error = "Your Passwords Must Match.";
}
elseif ($terms != "on") {
$error = "You Must Accept The Terms";
}
else {
$check_email = "SELECT email,username,password FROM members WHERE
email = '$email' OR
username = '$username' OR
password = '$pass1'";
$check_email_sql = MYSQL_QUERY($check_email) or die ("Could send email check");
$email_rows = MYSQL_NUMROWS($check_email_sql) or die ("couldnt check rows");
}
echo $email_rows;
?>
<br />
<u class="error"><?php echo $error ; ?></u>
<div id="space">
</div>
</div>
All help would be greatly appreciated!
Thanks