Jiraiya Posted November 24, 2008 Share Posted November 24, 2008 im using like a check box in my registration page but when i test the form nothing is put into the database when i select something with the check box here is the script im using // now we insert it into the database $insert = "INSERT INTO users (username, password, bloodline) VALUES ('".$_POST['username']."', '".$_POST['pass']."', '".$_POST['bloodline']."')"; $add_member = mysql_query($insert); ?> and this is the script im using for users to input and select data <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[]"> </td><td> oh and if someone could please tell me how to make it so users could only choose one option that would be great Link to comment https://forums.phpfreaks.com/topic/134057-solved-php-mysql-registration-form-help/ Share on other sites More sharing options...
flyhoney Posted November 24, 2008 Share Posted November 24, 2008 Use code tags plz. im using like a check box in my registration page but when i test the form nothing is put into the database when i select something with the check box here is the script im using <?php // now we insert it into the database $insert = "INSERT INTO users (username, password, bloodline) VALUES ('".$_POST['username']."', '".$_POST['pass']."', '".$_POST['bloodline']."')"; $add_member = mysql_query($insert); ?> and this is the script im using for users to input and select data <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[]"> </td><td> oh and if someone could please tell me how to make it so users could only choose one option that would be great Link to comment https://forums.phpfreaks.com/topic/134057-solved-php-mysql-registration-form-help/#findComment-697834 Share on other sites More sharing options...
flyhoney Posted November 24, 2008 Share Posted November 24, 2008 If you need users to only select one option, use radio buttons instead of checkboxes. That should solve both of your problems: Shariangan:<input type="radio" value="Shariangan" name="blood"><br /> Byuakugan:<input type="radio" value="Byuakugan" name="blood"><br /> 8 Inner Gates:<input type="radio" value="8 Inner Gates" name="blood"> <?php // now we insert it into the database $insert = "INSERT INTO users (username, password, bloodline) VALUES ('".$_POST['username']."', '".$_POST['pass']."', '".$_POST['blood']."')"; $add_member = mysql_query($insert); ?> Link to comment https://forums.phpfreaks.com/topic/134057-solved-php-mysql-registration-form-help/#findComment-697836 Share on other sites More sharing options...
revraz Posted November 24, 2008 Share Posted November 24, 2008 Yep, or a Select/Option list. Link to comment https://forums.phpfreaks.com/topic/134057-solved-php-mysql-registration-form-help/#findComment-697840 Share on other sites More sharing options...
Jiraiya Posted November 24, 2008 Author Share Posted November 24, 2008 it worked thanks Link to comment https://forums.phpfreaks.com/topic/134057-solved-php-mysql-registration-form-help/#findComment-697846 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.