overidemehra Posted October 24, 2008 Share Posted October 24, 2008 Hi, i was jsut wondering why does not my script allow to add details when i add the username, password and email. Thought it will not allow me to take the same username or email already present in my mysql table. It even goes thorugh when i add all new details , by saying that i have registered properly and i can login. But when i check in my mysql table, no new data is added. How to fix this? i am new to php... learnt over the net.... thanks <?php $action=$_GET["action"]; $uname = $_POST["user"]; $pword = $_POST["pass"]; $email = $_POST["email"]; $vpass = $pword; $user_name = "xxxxx"; $pass_word = "xxxxx"; $dbname="xxxx"; $table = "login"; $server = "xxxx"; $c=mysql_connect($server,$user_name, $pass_word, $table) OR DIE ('Unable to connect to database! Please try again later.'); $db_found=mysql_select_db($dbname); //if registering, check fields. if ($action == register) { if (!$uname || !$pword || !$email || !$vpass) { print "You must fill out all fields."; exit; } $dupe1 = mysql_num_rows(mysql_query("SELECT username FROM `$table` WHERE `username` = '$uname'")); if ($dupe1 > 0) { print "Someone already has that username."; exit; } $dupe2 = mysql_num_rows(mysql_query("SELECT email FROM `$table` WHERE `email` ='$email'")); if ($dupe2 > 0) { print "Someone already has that email."; exit; } //check if passwords are the same if ($pword != $vpass) { print "The passwords do not match."; exit; } //end //insert mysql_query("INSERT INTO login (username, email, pass) VALUES ('$uname','$email','$pword')"); print "You are now registered. Login."; } ?> <html> <body> <form method=post action=register.php?action=register name=s> <table> <tr><td>Username:</td><td><input type=text name=user></td></tr> <tr><td>Email:</td><td><input type=text name=email></td></tr> <tr><td>Pass:</td><td><input type=password name=pass></td></tr> <tr><td>Verify Pass:</td><td><input type=password name=vpass></td></tr> <tr><td colspan=2 align=center><input type=submit value=Register></td></tr> </table> </form> </body> </html> Quote Link to comment Share on other sites More sharing options...
overidemehra Posted October 24, 2008 Author Share Posted October 24, 2008 opps sorry wrong page to post this , pls delete this topic, i am reposting it on the php help side thank you Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.