Jump to content

[SOLVED] php mysql registration form help


Jiraiya

Recommended Posts

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

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

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);

?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.