Page 1 of 1

Coding issue request for Gene Howell[Solved]

Posted: Sat Sep 28, 2013 9:08 pm
by twizix
Hey Gene,

You requested I post the full code here, I have checked with the code to find the bracket but have come up empty handed. Here is the code

Code: Select all

<?php
include 'connect.php';
?>

<?php

$username=$_POST['user'];
$userpass=$_POST['password'];
$userpass2=$_POST['pass2'];
$username=strip_tags($username);
$usermail=$_POST['email'];
$usermail=strip_tags($usermail);

if ($usermail == "")
{
echo "You did not enter a email address.";
echo "<a href='register.php'>Please start over.</a></br>";
exit ;
}
if ($userpass == $userpass2)
{
$isuser="SELECT * from users where name='$username'";
$isuser2=mysql_query ($isuser) or die("Could not query users table.");
$isuser3=mysql_fetch_array($isuser2);
if(!$_POST['password'] || !$_POST['pass2'])
{
print "You did not eneter a password.";
echo "<a href='register.php'>Please start over.</a></br>";
exit ;
}
else if ($isuser || strlen($username)>21 || strlen($username) <1)
{
print "The user name you have chosen is already chosen or you have exceeded 21 letters. User names should be no less than 6 letter.";
echo "<a href='register.php'>Please start over.</a></br>";
exit ;
}
else
{
$ismail="SELECT * from users where email='$usermail'";
$ismail2=mysql_query ($ismail) or die ("Unable to query passphrase.");
$ismail3=mysql_fetch_array($ismail2);
if ($ismail3)
{
print "There is already a user with this email address.";
echo "<a href='register.php>Please start over.</a></br>'";
exit ;
}
else
{
$userpass=md5 ($userpass);
$SQL = "INSERT into users (name,password,email,level,exper) VALUES ('$username','$userpass','$usermail,'1','0'')";
mysql_query ($SQL) or die ("Could not register at this time.");

print "Thank you for registering.";

}
}
}

else
{
print "The passwords you entered did not match.";
echo "<a href='register.php'>Please start over.</a></br>";
exit ;
}

echo "<a href='login.php'>Please Login</a></br>"
?>
Thanks agaian,

JH

Re: Coding issue request for Gene Howell

Posted: Sat Sep 28, 2013 9:40 pm
by OldRod
I'm not Halls, but I looked through this. I don't see any missing brackets.

What error are you getting, and at what line?

Re: Coding issue request for Gene Howell

Posted: Sat Sep 28, 2013 9:55 pm
by twizix
Hello,

I'm sure anyone could help with this, it was just the first person i made contact with. Let me clear up by saying the code is not throwing any errors. The issue is the condition on the user name sign up field. It is stating that condition is true when I' am sure it is false. Username is more than 1 char and less than 21 the passwords match and the email is valid and not used before.

So the code seems to be reading that condition as true not matter what content is passed through it. ( I'm thinking I should be using brackets where i have parentheses in some places.)

Thanks,

JH

Re: Coding issue request for Gene Howell

Posted: Sat Sep 28, 2013 10:09 pm
by OldRod

Code: Select all

else if ($isuser || strlen($username)>21 || strlen($username) <1)
You are evaluating $isuser, which is your original query string. Don't you want to use $isuser3 here?

Re: Coding issue request for Gene Howell

Posted: Sun Sep 29, 2013 12:13 am
by hallsofvallhalla
yep thats the issue

Re: Coding issue request for Gene Howell

Posted: Sun Sep 29, 2013 12:20 am
by twizix
Yes thank you i did forget to amend the 3 to the end. Thanks again.