Jump to content

Archived

This topic is now archived and is closed to further replies.

master82

Retrieves blank data from dropdown box

Recommended Posts

I've created a form, on this form is a dropdown box with the name male (value=m) and female (value=f).

Once the form is submitted I am able to retrieve all the input data from the text fields - however the dropdown field always shows up as blank.

I'm using...

$gender=$_POST['gender'];

...to retrieve the values in a variable,

Any idea what I could be doing wrong?

Share this post


Link to post
Share on other sites
It would help if you posted the code for the drop-down. It sounds like you're not putting any values in the options... you're just echoing the selections between the option tags.

You should have:
<option value="male">male</option>

It sounds like you have:
<option>male</option> or just <option>male

Share this post


Link to post
Share on other sites
Heres the registration form:
[code]<form name="register" method="post" action="addme.php">
  <label>
  <p align="center">Requested Username<br>
      <input type="text" name="username" tabindex="1">
  </p>
  <p align="center">
    <label>Password<br>
    <input type="password" name="password" tabindex="2">
    </label>
  </p>
  <p align="center">
    <label>Verify Password<br>
    <input type="password" name="password2" tabindex="3">
    </label>
  </p>
  <p align="center">
    <label>Email<br>
    <input type="text" name="email" tabindex="4">
    </label>
  </p>
  <p align="center">
    <label>Gender<br>
    <select name="gender" tabindex="5">
      <option value="m">Male</option>
      <option value="f">Female</option>
    </select>
    </label>
  <p align="center">
    <input type="submit" name="Submit" value="Submit" tabindex="6">
</p>
</form>
[/code]

And here is part of the .php that processes it:
[code]
...
$username=$_POST['username'];
$password=$_POST['password'];
$password2=$_POST['password2'];
$email=$_POST['email'];
$gender=$_POST['gender'];
$joined=date("y-m-d");
...
[/code]

When I echo or print $gender its blank

See any problems?

Share this post


Link to post
Share on other sites
Amazing what a quick restart does!

Have no idea what changed but its working - I think I needed to empty my cache

Thanks anyway

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.