Drop Down Menu -> Mysql

White-Fox

New Member
Messages
3
Reaction score
0
Points
0
Hey, I'm trying to add data from a drop down menu into my database... But What I did does not work.

PHP:
<?php
if(isset($_POST['save']))
{
   $itemn   = $_POST['itemn'];
   $realm = $_POST["realm"];

   if(!get_magic_quotes_gpc())
   {
      $itemn   = addslashes($itemn);
   }

   $query = " INSERT INTO items (itemn, realm) ".
            " VALUES ('$itemn, '$realm')";
   mysql_query($query) or die('Error ,query failed');

   echo "'$itemn' on '$realm' added";
}
?>
<form method="post">
<table width="700" border="0" cellpadding="2" cellspacing="1" align="center">
<tr>
<td width="100">Item Name</td>
<td><input name="itemn" type="text"></td>
</tr>
<tr>
<td width="100">Realm</td>
<td>


<select name="realm">
    <option value="------" >Select one</option>
    <option value="Us.East N-L Sofcore">Us.East N-L Sofcore</option>
    <option value="Us.East N-L Hardcore">Us.East N-L Hardcore</option>
    <option value="Us.East L Softcore">Us.East L Softcore</option>      
    <option value="Us.East L Hardcore">Us.East L Hardcore</option>
    <option value="Us.West N-L Sofcore">Us.West N-L Sofcore</option>
    <option value="Us.West N-L Hardcore">Us.West N-L Hardcore</option>
    <option value="Us.West L Softcore">Us.West L Softcore</option>        
    <option value="Us.West L Hardcore">Us.West L Hardcore</option>
    <option value="Europe N-L Sofcore">Europe N-L Sofcore</option>
    <option value="Europe N-L Hardcore">Europe N-L Hardcore</option>
    <option value="Europe L Softcore">Europe L Softcore</option>             
    <option value="Europe L Hardcore">Europe L Hardcore</option>           
    <option value="Asia N-L Sofcore">Asia N-L Sofcore</option>
    <option value="Asia N-L Hardcore">Asia N-L Hardcore</option>
    <option value="Asia L Softcore">Asia L Softcore</option>           
    <option value="Asia L Hardcore">Asia L Hardcore</option>
</select>

</td>
</tr>
</table>

<input name="save" type="submit" value="Save Item">
</form>
 

leafypiggy

Manager of Pens and Office Supplies
Staff member
Messages
3,819
Reaction score
163
Points
63
you don't specifiy an action to do once submit is pressed.

you gotta change
Code:
<form method="post">

to

Code:
<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">


that will just make the form submit the values to taht file that you have the proccessing of the form.
 

White-Fox

New Member
Messages
3
Reaction score
0
Points
0
you don't specifiy an action to do once submit is pressed.

you gotta change
Code:
<form method="post">
to

Code:
<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
that will just make the form submit the values to taht file that you have the proccessing of the form.

It is not that at all

PHP:
" VALUES ('$itemn, '$realm')";
I forgot a ' after the itemn
 
Last edited:
Top