Twister1004 Posted October 26, 2008 Share Posted October 26, 2008 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? =) Link to comment https://forums.phpfreaks.com/topic/130198-solved-selecting-a-value-in-an-option-within-php/ Share on other sites More sharing options...
Pezmc Posted October 26, 2008 Share Posted October 26, 2008 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 Link to comment https://forums.phpfreaks.com/topic/130198-solved-selecting-a-value-in-an-option-within-php/#findComment-675234 Share on other sites More sharing options...
DarkWater Posted October 26, 2008 Share Posted October 26, 2008 Yeah, it follows the rules of all the other form elements. Link to comment https://forums.phpfreaks.com/topic/130198-solved-selecting-a-value-in-an-option-within-php/#findComment-675245 Share on other sites More sharing options...
Twister1004 Posted October 26, 2008 Author Share Posted October 26, 2008 OK thanks very much Link to comment https://forums.phpfreaks.com/topic/130198-solved-selecting-a-value-in-an-option-within-php/#findComment-675260 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.