Login Help

From: Date: Mon, 09 Jul 2001 00:48:25 +0000
Subject: Login Help
Groups: php.db 
Request: Send a blank email to php-db+get-10162@lists.php.net to get a copy of this message
Hello all, I seem to be missing something with my login script, I have a couple of issues: 1) When you do not enter any informaton, it will say: "Please fill out all fields to proceed. There seems to be a problem with the database." Now, if i hit enter again it will say: "Please fill out all fields to proceed. Sorry, username is already taken, please choose another. There seems to be a problem with the database." and if you enter information into all hte fields it will give you what it is suppose to: "Thank you for registering, You may go here to login "link here"" What am I missing? if you find any other bugs, please let me know Thanks for any help. Kevin Here is my code: ------------------------------------------------ <html><head> <title>Register</title></head> <body> <form method=post action="<? echo $PHP_SELF; ?>"> <table cellpadding=2 cellspacing=0 border=0> <td>Username:</td><td><input type="text" name="username" size=10></td><tr> <td>Password:</td><td><input type="password" name="password" size=10></td><tr> <td>Email:</td><td><input type="text" name="email" size=15></td><tr> <td> </td><td><input type="submit" name="submit" value="register"></td> </table></form> </body> </html> <?php include'dbcon.inc'; if(isset($submit)) { dbConnect('login'); // Make sure all fields are filled out if ($username=="" or $password=="" or $email=="") { echo("Please fill out all fields to proceed.<br>"); } // Make sure there is not the same name in the database $query = "SELECT COUNT(*) FROM user WHERE name = '$username'"; $result = mysql_query($query); if (!$result) { echo("There seems to be a problem with the database.<br>"); } if (mysql_result($result,0,0)>0) { echo("Sorry, username is already taken, please choose another.<br>"); } //Insert info into databse $query2="INSERT INTO user (name, password, email) VALUES ('$username', '$password', '$email')"; $result2 = mysql_query($query2); if (!$result2) { echo("There seems to be a problem with the database.<br>"); } else { echo'Thank you for registering, You may go here to login "link here"'; } } ?>

« previous php.db (#10162) next »