+ Reply to Thread
Results 1 to 5 of 5

Thread: Passing a value from a select input field using php

  1. #1
    unionguy is offline x10Hosting Member unionguy is an unknown quantity at this point
    Join Date
    Feb 2009
    Posts
    5

    Passing a value from a select input field using php

    Greetings,

    I'm having a problem getting select fields to pass information on my registration form for membership. I have text fields down pat but my select fields are a big problem for me.

    I searched the forums for any issues that may have been posted previously and didn't find any.

    Basically I want visitors applying for membership to select options that pretain to them, then pass that info to my database. If anyone can give me an idea on how to pass info from select fields (all I need is the general idea) I'd love you for life!

    Thanks in advance!

  2. #2
    xPlozion's Avatar
    xPlozion is offline x10 Elder xPlozion is an unknown quantity at this point
    Join Date
    Mar 2008
    Location
    Delaware, USA
    Posts
    872

    Re: Passing a value from a select input field using php

    ok, here's the syntax for a select field ;)

    HTML Code:
    <form action="./" method="post">
      <select name="gender">
        <option value="m">Male</option>
        <option value="f">Female</option>
      </select><br />
      <input name="submit" type="submit" value="Check" />
    </form>
    PHP Code:
    <?php
    if (isset($_POST['submit']) && !empty($_POST['gender']))
    {
      echo 
    $_POST['gender']; //will output either m or f.
    }
    ?>
    if you need more help or would like for me to go more in-depth, just ask

  3. #3
    unionguy is offline x10Hosting Member unionguy is an unknown quantity at this point
    Join Date
    Feb 2009
    Posts
    5

    Re: Passing a value from a select input field using php

    Looks good ^_^;

    Will try that out asap!

    I'll let ya know if I need more indepthness :D

    You are now on my love list! Congrats!

  4. #4
    unionguy is offline x10Hosting Member unionguy is an unknown quantity at this point
    Join Date
    Feb 2009
    Posts
    5

    Re: Passing a value from a select input field using php

    3 more questions for you.

    1st: I do include the <?php script in the form right? Or would it be better to add it to my form validation script?

    2nd: How would I write the script to make sure that the user registering has to make a choice from the select field?

    3rd: How do I pass a value from only 1 checkbox and make it so the user has to check the box before processing the form? Example: I want users to agree to terms and conditions of use for my site and the user must check this to continue and then store that information into my database.


    Edit:
    On second thought... Don't reply to this.

    I'm going to follow a golden rule in life for this...


    K.I.S.S

    Keep it simple, stupid.

    It will make things easier for me and I shouldn't burden others with my lack of php knowledge. Once my programming skills get better, I will then attempt the select thing. Until then, I will stick with what I know

    Thanks everyone, and sorry for the waste of thread space ;) lol.
    Last edited by unionguy; 02-16-2009 at 12:44 PM. Reason: Automerged Doublepost

  5. #5
    gomarc's Avatar
    gomarc is offline x10 Elder gomarc is an unknown quantity at this point
    Join Date
    Oct 2007
    Location
    USA
    Posts
    511

    Re: Passing a value from a select input field using php

    Quote Originally Posted by unionguy View Post

    ... Once my programming skills get better, I will then attempt the select thing. Until then, I will stick with what I know
    A great place to learn PHP is w3schools.com

    It's full of good tutorials.

+ Reply to Thread

Similar Threads

  1. tons of PHP Resources
    By Chris S in forum Scripts & 3rd Party Apps
    Replies: 10
    Last Post: 01-16-2009, 10:07 AM
  2. Places to learn php
    By JaWasabi in forum Scripts & 3rd Party Apps
    Replies: 9
    Last Post: 01-13-2009, 02:03 AM
  3. Replies: 0
    Last Post: 12-24-2008, 03:59 PM
  4. [PHP] PHP For Starters
    By Complex in forum Tutorials
    Replies: 24
    Last Post: 06-14-2008, 11:40 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers