PDA

View Full Version : Radio/Dropdown Fields



SChaput
11-22-2008, 12:36 AM
I am making a form where i need the user to select one of two radio buttons, enter some text fields and select info from a drop down box. I know how to put the text fields into a database, but im not sure how to put in the radio button value, and the drop-down box value.
The below code is what i have to add the text fields.


<?php
if ($HTTP_POST_VARS['submit']) {
mysql_connect("freshsql.com:","","");
mysql_select_db("");
$entrytitle=$HTTP_POST_VARS['entrytitle'];
$entrytext=$HTTP_POST_VARS['entrytext'];
$entrytime=$HTTP_POST_VARS['entrytime'];
$query ="INSERT INTO weblog (entrytitle,entrytext,entrytime)";
$query.=" VALUES ('$entrytitle','$entrytext', '$entrytime')";
$result=mysql_query($query);
if ($result) echo "<b>Successfully Posted!</b>";
else echo"ERROR";


}
?>
<p><a href="index.php">Click Here to View</a></p>


Any help is greatly appreciated. THanks.

prasanthmj
11-24-2008, 05:16 PM
For select box, see the examples in the page:
select box in a PHP form (http://www.html-form-guide.com/php-form/php-form-select.html)

For radio,
HTML sample:


<input type="radio" group="membership_type" value="Free">
<input type="radio" group="membership_type" value="Normal">
<input type="radio" group="membership_type" value="Deluxe">

PHP handling


$type = $_POST['membership_type'];