| | |||||
| ||||||||
| Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics. |
![]() |
| | LinkBack | Thread Tools |
| | THREAD STARTER #1 (permalink) |
| NamePros Regular Join Date: Dec 2005
Posts: 208
![]() | how to INSERT data from drop down into MySQL DB?? Can anyone please help me do this? I have a registration form that when submitted, only the text fields are inserted and saved in the database. I have one drop down selection menu for users to choose their state. When the form is submitted the state they selected is not inserted into the database, but all the other information is. let me know if you need to see any more code. I would really appreciate if someone could give me some pointers, or maybe even code that would work. here is the code i have for the drop down Code: <td><font size="2" face="Verdana"> <strong>State</strong></font></td>
<td>
<select name='State'>
<option value='Alabama'>Alabama
<option value='Alaska'>Alaska
<option value='Arizona'>Arizona
</select> here is the code in register.php that is supposed to "register" the user: Code: user_register ($_POST['username'], $_POST['password'], $_POST['email'], $_POST['firstname'], $_POST['lastname'], $_POST['address'], $_POST['city'], $_POST['state'], $_POST['zip']); Code: function user_register($username, $password, $email, $firstname, $lastname, $address, $city, $state, $zip)
{
// Get a salt using our function
$salt = generate_salt();
// Now encrypt the password using that salt
$encrypted = md5(md5($password).$salt);
// And lastly, store the information in the database
$query = "INSERT INTO user (username, password, email, firstname, lastname, address, city, state, zip, salt) values ('$username', '$encrypted', '$email', '$firstname', '$lastname', '$address', '$city', '$state', '$zip', '$salt')";
$result = mysql_query($query) or die ('Could not create user.');
__________________ + Domains I have for sale here |
| |
| | #3 (permalink) |
| NamePros Regular Join Date: Jul 2006 Location: England
Posts: 721
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() | Try changing Code: <td><font size="2" face="Verdana"> <strong>State</strong></font></td>
<td>
<select name='State'>
<option value='Alabama'>Alabama
<option value='Alaska'>Alaska
<option value='Arizona'>Arizona
</select> Code: <td><font size="2" face="Verdana"> <strong>State</strong></font></td>
<td>
<select name='state'>
<option value='Alabama'>Alabama
<option value='Alaska'>Alaska
<option value='Arizona'>Arizona
</select> |
| |
| | THREAD STARTER #4 (permalink) |
| NamePros Regular Join Date: Dec 2005
Posts: 208
![]() | wow thank you sooo much! that was the problem, so simple to solve but i had no idea that the capitalization mattered. thanks! it works perfectly now, and i have learned something too. lol
__________________ + Domains I have for sale here |
| |