Jiraiya Posted November 24, 2008 Share Posted November 24, 2008 im using radio boxes and its only displaying the first 3 "village" results and im not sure why here is the code if ($_POST['pass'] != $_POST['pass2']) { die('Your passwords did not match. '); } // here we encrypt the password and add slashes if needed $_POST['pass'] = md5($_POST['pass']); if (!get_magic_quotes_gpc()) { $_POST['pass'] = addslashes($_POST['pass']); $_POST['username'] = addslashes($_POST['username']); } // now we insert it into the database $insert = "INSERT INTO users (username, password, bloodline, village) VALUES ('".$_POST['username']."', '".$_POST['pass']."', '".$_POST['bloodline']."', '".$_POST['village']."',)"; $add_member = mysql_query($insert); ?> <h1>Registered</h1> <p>Thank you, you have registered - you may now login</a>.</p> <?php } else { ?> <center> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> <table border="0"> <tr><td>Username:</td><td> <input type="text" name="username" maxlength="60"> </td></tr> <tr><td>Password:</td><td> <input type="password" name="pass" maxlength="10"> </td></tr> <tr><td>Confirm Password:</td><td> <input type="password" name="pass2" maxlength="10"> </td></tr> <tr><td> Please choose an ability:<br /> Shariangan:<input type="checkbox" value="Shariangan" name="blood[]"><br /> Byuakugan:<input type="checkbox" value="Byuakugan" name="blood[]"><br /> 8 Inner Gates:<input type="checkbox" value="8 Inner Gates" name="blood[]"> <center><H2>Pick a Village to start in</H2><br> <center> Hidden Village of Konoha:<input type="checkbox" value="Konoha" name="village[]"><br /> Hidden Village of Mist:<input type="checkbox" value="Mist" name="village[]"<br /> Hidden Village of Sand:<input type="checkbox" value="Sand" name="village[]<br /> Hidden Village of Rock:<input type="checkbox" value="Rock" name="village[]<br /> Hidden Village of Cloud:<input type="checkbox" value="Cloud" name="village[]<br /> </td><td> Link to comment https://forums.phpfreaks.com/topic/134112-solved-php-registration-help/ Share on other sites More sharing options...
realshadow Posted November 24, 2008 Share Posted November 24, 2008 One reason would be that you did not end inputs of villages correctly. You forgot to add "> Try to change it if you havent yet and see if it works. And one more thing, you have a typo there - change "Shariangan" to "Sharingan" Link to comment https://forums.phpfreaks.com/topic/134112-solved-php-registration-help/#findComment-698147 Share on other sites More sharing options...
revraz Posted November 24, 2008 Share Posted November 24, 2008 Why do you use a Checkbox for these, shouldn't they be radio buttons? I wouldn't think you would allow more than one choice for a starting village or a ability. Link to comment https://forums.phpfreaks.com/topic/134112-solved-php-registration-help/#findComment-698163 Share on other sites More sharing options...
waynew Posted November 24, 2008 Share Posted November 24, 2008 How about keeping it clean and simple and using a menu? Link to comment https://forums.phpfreaks.com/topic/134112-solved-php-registration-help/#findComment-698165 Share on other sites More sharing options...
revraz Posted November 24, 2008 Share Posted November 24, 2008 Seems we already went through all this http://www.phpfreaks.com/forums/index.php/topic,226969.0.html Link to comment https://forums.phpfreaks.com/topic/134112-solved-php-registration-help/#findComment-698172 Share on other sites More sharing options...
Jiraiya Posted November 24, 2008 Author Share Posted November 24, 2008 i did some fixing and now it wont send anything to my database. //This code runs if the form has been submitted if (isset($_POST['submit'])) { //This makes sure they did not leave any fields blank if (!$_POST['username'] | !$_POST['pass'] | !$_POST['pass2'] ) { die('You did not complete all of the required fields'); } // checks if the username is in use if (!get_magic_quotes_gpc()) { $_POST['username'] = addslashes($_POST['username']); } $usercheck = $_POST['username']; $check = mysql_query("SELECT username FROM users WHERE username = '$usercheck'") or die(mysql_error()); $check2 = mysql_num_rows($check); //if the name exists it gives an error if ($check2 != 0) { die('Sorry, the username '.$_POST['username'].' is already in use.'); } // this makes sure both passwords entered match if ($_POST['pass'] != $_POST['pass2']) { die('Your passwords did not match. '); } // here we encrypt the password and add slashes if needed $_POST['pass'] = md5($_POST['pass']); if (!get_magic_quotes_gpc()) { $_POST['pass'] = addslashes($_POST['pass']); $_POST['username'] = addslashes($_POST['username']); } // now we insert it into the database $insert = "INSERT INTO users (username, password, bloodline, village) VALUES ('".$_POST['username']."', '".$_POST['pass']."', '".$_POST['bloodline']."', '".$_POST['village']."',)"; $add_member = mysql_query($insert); ?> <h1>Registered</h1> <p>Thank you, you have registered - you may now login</a>.</p> <?php } else { ?> <center> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> <table border="0"> <tr><td>Username:</td><td> <input type="text" name="username" maxlength="60"> </td></tr> <tr><td>Password:</td><td> <input type="password" name="pass" maxlength="10"> </td></tr> <tr><td>Confirm Password:</td><td> <input type="password" name="pass2" maxlength="10"> </td></tr> <tr><td> Please choose an ability:<br /> Sharingan:<input type="checkbox" value="Sharingan" name="bloodline[]"><br /> Byuakugan:<input type="checkbox" value="Byuakugan" name="bloodline[]"><br /> 8 Inner Gates:<input type="checkbox" value="8 Inner Gates" name="bloodline[]"> <center><H2>Pick a Village</H2><br> Hidden Village Konoha:<input type="checkbox" value="Konoha" name"village[]"><br /> Hidden Village Rock:<input type="checkbox" value="Rock" name"village[]"><br /> Hidden Village Sand:<input type="checkbox" value="Sand" name"village[]"><br /> Hidden Village Mist:<input type="checkbox" value="Mist" name"village[]"><br /> Hidden Village Cloud:<input type="checkbox" value="Cloud" name"village[]"><br /> </td> <tr><th colspan=0><input type="submit" name="submit" value="Register"></th></tr> </table> </form> <?php } ?> Link to comment https://forums.phpfreaks.com/topic/134112-solved-php-registration-help/#findComment-698174 Share on other sites More sharing options...
Jiraiya Posted November 24, 2008 Author Share Posted November 24, 2008 ok i fixed all but one of the registration i submit one part and it appears in the database as "Array" Link to comment https://forums.phpfreaks.com/topic/134112-solved-php-registration-help/#findComment-698179 Share on other sites More sharing options...
realshadow Posted November 25, 2008 Share Posted November 25, 2008 Using radio box for these would be better since I cant imagine someone with sharingan in one eye and byublabla in second eye. Also if you get an array its propably because of name you give to each checkbox. "village[]" should be used for arrays, its kinda same as array_push(). Give them names like village1, village2, etc. Link to comment https://forums.phpfreaks.com/topic/134112-solved-php-registration-help/#findComment-698446 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.