Monk3h Posted April 23, 2008 Share Posted April 23, 2008 When i fill out this form completly and click the Register image why does the error apear saying i havnt filled in a user name when i have? This should work.. It did work before, its just dosnt now and i dont know what iv done. Any help? =/ <?php include ("head.php"); ?> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Untitled Document</title> <style type="text/css"> <!-- body { background-color: #D1BFAB; } .style1 { font-family: "Gill Sans MT"; color: #804040; } --> </style></head> <?php Print"<form method=post action='register.php?action=register'> <body><center> <table width='755' height='482' border='0' cellpadding='0' cellspacing='0' bgcolor='#D1BFAB'> <tr> <td height='95' colspan='3' background='images/topimg.png'> </td> </tr> <tr> <td width='42' height='395' rowspan='2' background='images/leftimg.png'> </td> <td width='676' background='images/middleimg2.png'><img src='images/banner.png' width='676' height='100' /></td> <td width='42' rowspan='2' background='images/rightimg.png'> </td> </tr> <tr> <td height='184' background='images/middleimg2.png'><table width='679' border='0' cellpadding='0' cellspacing='0'> <tr> <td height='87' colspan='2'><p align='center' class='style1'><img src='images/rmessage.png' width='500' height='150'></p> </td> </tr> <tr> <td width='96' height='22'><img src='images/ruser.png' width='150' height='20' /></td> <td width='583'><label> <input type='text' name='name'/> </label></td> </tr> <tr> <td><div align='left'><img src='images/remail.png' width='150' height='20' /></div></td> <td><input type='text' name='email' /></td> </tr> <tr> <td><div align='left'><img src='images/rpass.png' width='150' height='20' /></div></td> <td><input type='password' name='pass' /></td> </tr> <tr> <td><img src='images/rgender.png' width='150' height='20'></td> <td><label> <select name='gender'> <option>Male</option> <option>Female</option> </select> </label></td> </tr> <tr> <td height='34'><div align='left'><a href='index.php'><img src='images/back.png' width='150' height='20' border='0' /></a></div></td> <td><a href='register.php?action=register'><img src='images/signup.png' width='150' height='30' border='0' /></a></td> </tr> </table></td> </tr> <tr> <td colspan='3'><img src='images/bottomimg.png' width='760' height='103' /></td> </tr> </table> </center></form>"; if ($action == register) { if (!$name) { print "Please enter a User Name."; // Line 73 exit; } if (!$email) { print "Please enter an Email Address."; exit; if (!$pass) { print "Please enter a Password."; exit; } } $dupe1 = mysql_num_rows(mysql_query("select * from players where user='$user'")); if ($dupe1 > 0) { print "Someone already has that username."; exit; } $dupe2 = mysql_num_rows(mysql_query("select * from players where email='$email'")); if ($dupe2 > 0) { print "Someone already has that email."; exit; }else{ mysql_query("insert into players (user, email, pass, gender) values('$user','$email','$pass','$gender')") or die("Could not register."); print "You are now registered to play, $user."; print "<br><a href=index.php>login</a>"; exit; }} ?> </body> Link to comment https://forums.phpfreaks.com/topic/102563-form-is-bringing-back-errors-when-its-not-ment-to/ Share on other sites More sharing options...
micah1701 Posted April 23, 2008 Share Posted April 23, 2008 perhaps you (correctly) have globals turned off. That would explain why php thinks the $name variable is not set. change $name to $_POST['name'] and see what happens. (my guess is that it will throw "no e-mail address" error) Link to comment https://forums.phpfreaks.com/topic/102563-form-is-bringing-back-errors-when-its-not-ment-to/#findComment-525158 Share on other sites More sharing options...
Monk3h Posted April 23, 2008 Author Share Posted April 23, 2008 DB Globals are on.. Just to make sure i did as you said and it still come up with the same user name error. I dont have a clue why its not working.. :S Link to comment https://forums.phpfreaks.com/topic/102563-form-is-bringing-back-errors-when-its-not-ment-to/#findComment-525166 Share on other sites More sharing options...
micah1701 Posted April 23, 2008 Share Posted April 23, 2008 how about this adding this: echo "<pre>"; print_r($_POST); echo "</pre>"; when you submit the form, it should print out an array of all the data that was posted. does it show that the name var has a value? Link to comment https://forums.phpfreaks.com/topic/102563-form-is-bringing-back-errors-when-its-not-ment-to/#findComment-525182 Share on other sites More sharing options...
johnny44 Posted April 23, 2008 Share Posted April 23, 2008 You're using an image as your submit button, but you can't do it your way: <a href='register.php?action=register'><img src='images/signup.png' width='150' height='30' border='0' /></a> That's just a hyperlink. No wonder no variables are going through. You need this as your submit button: <input type='image' src='images/signup.png' width='150' height='30' border='0' /> Link to comment https://forums.phpfreaks.com/topic/102563-form-is-bringing-back-errors-when-its-not-ment-to/#findComment-525189 Share on other sites More sharing options...
Monk3h Posted April 23, 2008 Author Share Posted April 23, 2008 LEGEND.. Works now, Thanks dude. But im so confused.. It worked before.. I havnt changed a thing. Then it just Stoped. :S But it works fine now. Thanks Guys! Link to comment https://forums.phpfreaks.com/topic/102563-form-is-bringing-back-errors-when-its-not-ment-to/#findComment-525195 Share on other sites More sharing options...
Monk3h Posted April 23, 2008 Author Share Posted April 23, 2008 Okay now it keeps saying someone already has that username after i signed up the first time.. WTF? Link to comment https://forums.phpfreaks.com/topic/102563-form-is-bringing-back-errors-when-its-not-ment-to/#findComment-525198 Share on other sites More sharing options...
Monk3h Posted April 23, 2008 Author Share Posted April 23, 2008 Its because it added the username as nothing.. and its trying to do it again but it cant because its already taken. Im so confused.. :S Link to comment https://forums.phpfreaks.com/topic/102563-form-is-bringing-back-errors-when-its-not-ment-to/#findComment-525203 Share on other sites More sharing options...
Monk3h Posted April 23, 2008 Author Share Posted April 23, 2008 Okay, Fixed it now. Thanks guys. Link to comment https://forums.phpfreaks.com/topic/102563-form-is-bringing-back-errors-when-its-not-ment-to/#findComment-525208 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.