Doh same problem here is the entier script I have tracked it to the if statement through testing it without the if and checking the db and nothing was missing but here it is lol. I warn you don't criticze the first few empty lines as they are not going to be in there as they are useless atm and do nothing to stop anything. I have there so they can help me debug as it warns me if I forgot a field. 😃
<?php
//register.php
//Created By: Bill Lewis
include "./common_db.inc";
echo "<html>";
echo "<head></head>";
echo "<body>";
if(empty($_POST['username'])) echo "Go enter a username!<br>";
if(empty($_POST['userpass'])) echo "Go enter a userpassword!<br>";
if(empty($_POST['useremail'])) echo "Go enter a useremail!<br>";
if(empty($_POST['userempirename'])) echo "Go enter a userempier!<br>";
If(empty($_POST['align'])) echo "Go enter a alignment!<br>";
$useralign = HTMLSpecialChars($_POST['align']);
$privi = 0;
//validity RegExp checks
function checkusername($useradd)
{
$utestres = ereg("[a-z]{2,8}", $useradd);
if(!$utestres)
{
echo "Invalid character in username put another!<br>";
}
else
{
return $useradd;
}
}
$username = checkusername($_POST['username']);
function checkuserpass($passadd)
{
$ptestres = ereg("[0-9]{8}", $passadd);
if(!$ptestres)
{
echo "Not a valid password put another!<br>";
}
else
{
return $passadd;
}
}
$userpass = checkuserpass($_POST['userpass']);
function checkemail($emailadd)
{
$emtestres = ereg("^.+@.+\\..+$", $emailadd);
if(!$emtestres)
{
echo "Invalid e-mail address go put another<br>";
}
else
{
return $emailadd;
}
}
$useremail = checkemail($_POST['useremail']);
function checkuserempire($uemp)
{
$emptestres = ereg("[A-Z]{8}", $uemp);
if(!$emptestres)
{
echo "Please go back and enter a valid empiername!<br>";
}
else
{
return $uemp;
}
}
$userempire = checkuserempire($_POST['userempirename']);
//create DB connection
$link_id = db_connect();
if (!$link_id) die(sql_error());
//check and insert record
function checkandinsert($user, $pass, $email, $empier, $align, $priv)
{
$username = $user;
$userpass = $pass;
$useremail = $email;
$userempire = $empier;
$useralign = $align;
$privi = $priv;
$chkuser = "SELECT userid, userempire FROM user WHERE
(userid = '$username' OR userempire = '$userempire')
LIMIT 1";
$chkuserq = mysql_query($chkuser);
$result = mysql_num_rows($chkuserq);
if ($result > 0)
{
echo "This user and or empire is in existance please
pick another!<br>";
}
else
{
//check to see if vars are empty if so make correction.
$adduser = "INSERT INTO user (userid, userpassword, useremail,
registerdate, userpriv, userempire, useralignment)
VALUES('$username', Password($userpass),
'$useremail', curdate(), '$privi',
'$userempire', '$useralign')";
$insert = mysql_query($adduser);
//check to see if query was fine if so insert record to db
if(!$insert)
{
echo "We encountered a problem puting you in the EOTA
Database please contact the game programer at:
<a href=\"mailto: [email]tekronx@adelphia.net[/email]\">Tekron-X</a>
with the following error! $nbsp;" . mysql_error();
}
else
{
echo "Welcome to EOTA you can now login and begin your
race to save the world. <a href=\"login.php\">
CLICK HERE TO LOGIN!!!</a>";
}
}
}
if($username == "" or $userpass == "" or $useremail == ""
or $userempire == "" or $useralign == "" or $privi == "")
{
echo "Go Back and fill in all fields or enter proper characters.";
}
else
{
checkandinsert($username, $userpass, $useremail, $userempire,
$useralign, $privi);
}
mysql_close($link_id);
?>