Jump to content


Photo

Retrieves blank data from dropdown box


  • Please log in to reply
3 replies to this topic

#1 master82

master82
  • Members
  • PipPipPip
  • Advanced Member
  • 182 posts

Posted 07 June 2006 - 01:54 PM

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?

#2 ober

ober
  • Staff Alumni
  • Advanced Member
  • 5,337 posts
  • LocationEast Coast, USA

Posted 07 June 2006 - 02:37 PM

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

Info: PHP Manual


#3 master82

master82
  • Members
  • PipPipPip
  • Advanced Member
  • 182 posts

Posted 07 June 2006 - 06:36 PM

Heres the registration form:
<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>

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

When I echo or print $gender its blank

See any problems?

#4 master82

master82
  • Members
  • PipPipPip
  • Advanced Member
  • 182 posts

Posted 07 June 2006 - 06:55 PM

Amazing what a quick restart does!

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

Thanks anyway




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users