Coding issue request for Gene Howell[Solved]

Place for questions and answers for all newcomers and new coders. This is a free for all forum, no question is too stupid and to noob.
Post Reply
twizix
Posts: 5
Joined: Sat Sep 28, 2013 9:02 pm

Coding issue request for Gene Howell[Solved]

Post 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
Last edited by twizix on Sun Sep 29, 2013 5:44 am, edited 1 time in total.
User avatar
OldRod
Posts: 1320
Joined: Sun Sep 20, 2009 4:26 pm

Re: Coding issue request for Gene Howell

Post 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?
twizix
Posts: 5
Joined: Sat Sep 28, 2013 9:02 pm

Re: Coding issue request for Gene Howell

Post 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
User avatar
OldRod
Posts: 1320
Joined: Sun Sep 20, 2009 4:26 pm

Re: Coding issue request for Gene Howell

Post 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?
User avatar
hallsofvallhalla
Site Admin
Posts: 12026
Joined: Wed Apr 22, 2009 11:29 pm

Re: Coding issue request for Gene Howell

Post by hallsofvallhalla »

yep thats the issue
twizix
Posts: 5
Joined: Sat Sep 28, 2013 9:02 pm

Re: Coding issue request for Gene Howell

Post by twizix »

Yes thank you i did forget to amend the 3 to the end. Thanks again.
Post Reply

Return to “Beginner Help and Support”