Jump to content

[SOLVED] Selecting a value in an option within PHP


Twister1004

Recommended Posts

Hey everyone, just a slight problem. I I'm kinda thinking about it too hard and confusing myself about how to call a value from a select in Hmtl.

 

objective: Can ya help me figure out how to call its value?

 

info:

 

Well, as i described, this is basically a FORM going through with values of a select option.

This here is the layout of the stuff.

<form METHOD="POST" ACTION="">
<table width="396" border="1" cellspacing="1" cellpadding="2">
  <tr>
    <td><center>Your Age:</center></td>
    <td><center><input type="text" name="age" maxlength="2" ></center></td>
  </tr>
  <tr>
    <td><center>E-mail:<br/> Please do not fake your E-mail</center></td>
    <td><center><input type="text" name="email" maxlength="30" ></center></td>
  </tr>
  <tr>
    <td><center>Date of Birth:<br/>YYYY-MM-DD</center></td>
    <td><center><input type="text" name="dob" maxlength="10" ></center></td>
  </tr>
  <tr>
    <td><center>Second or Real Life?</center></td>
    <td><center>
			<select name="life">
			<option value="Real">Real Life</option>
			<option value="Second" selected="selected">Second Life</option>
			</select>
	</center></td>
  </tr>
  <tr>
    <td><center>Looking for:</center></td>
    <td><center>	
			<select name="looking">
			<option value="Friends" selected="selected">Friends</option>
			<option value="Men">Male</option>
			<option value="Women">Female</option>
			</select>
	</center></td>
  </tr>
  <tr>
    <td><center>Sexuality:</center></td>
    <td><center>
			<select name="going">
			<option value="Straight">Straight</option>
			<option value="Gay">Gay</option>
			<option value="Bi">Bi</option>
			</select>
	</center></td>
  </tr>
  <tr>
    <td><center>Status:</center></td>
    <td><center>
			<select name="status">
			<option value="unknown">Not Telling</option>
			<option value="Single">Single</option>
			<option value="Married">Married</option>
			</select>
	</center></td>
  </tr>
</table>

<input name="submit" type="submit" id="submit" value="Submit" />
</form>

 

Now what I don't get is how to call the value from a select option.

here is my php script for it so far

<?php

if(!isset($_POST['submit'])){
// echo "Sorry, your information could not be completed at this time. Please contact an Admin.";
}
else{
isset($_SESSION['login_user']);
$age = mysql_real_escape_string($_POST['age']);
$email = mysql_real_escape_string($_POST['email']);
$dob = mysql_real_escape_string($_POST['dob']);
}
?>

 

As you see, I havent done anything with the ones from the select option.

 

Any hints or tips? =)

If you are asking what I think you are its exactly as with the other ones

$status = mysql_real_escape_string($_POST['status']);
$going = mysql_real_escape_string($_POST['going']);
$looking = mysql_real_escape_string($_POST['looking']);
$life = mysql_real_escape_string($_POST['life']);

 

PHP will just get the "value" of selected option in the box

Archived

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

×
×
  • Create New...

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.