Results 1 to 2 of 2

Thread: Radio/Dropdown Fields

  1. #1
    Join Date
    Feb 2008
    Posts
    90
    Thanks
    3
    Thanked 2 Times in 2 Posts

    Default Radio/Dropdown Fields

    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.
    Code:
    <?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.

  2. #2
    Join Date
    Nov 2008
    Posts
    58
    Thanks
    0
    Thanked 7 Times in 7 Posts

    Default

    For select box, see the examples in the page:
    select box in a PHP form

    For radio,
    HTML sample:

    Code:
    <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

    PHP Code:
    $type $_POST['membership_type']; 

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •