Passing a value from a select input field using php

unionguy

New Member
Messages
5
Reaction score
0
Points
0
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!
 

xPlozion

New Member
Messages
868
Reaction score
1
Points
0
ok, here's the syntax for a select field ;)

HTML:
<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:
<?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 :)
 

unionguy

New Member
Messages
5
Reaction score
0
Points
0
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!
 

unionguy

New Member
Messages
5
Reaction score
0
Points
0
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:
Top