Jump to content

<option> And Php?


EmperorZenos

Recommended Posts

When they submit the form the value that they selected will be submitted under the name of the select element. If you have a select element called "test", and a chosen option with a value of "abc", and the form is submitted using the post method, in PHP the variable $_POST['test'] will have the value "abc".

Link to comment
Share on other sites

<form action='mypage.php' method='post>  <select name='something'>	<option value='this' />this	<option value='that' />that  </select>  <input type='submit' value='submit'></form>

mypage.php can then access that information with...

<?php  if ($_POST['something'] = 'this')  {	 echo 'this was selected'  }  else  {	 echo 'that was selected'  }?>

Link to comment
Share on other sites

<form action='mypage.php' method='post>  <select name='something'>	<option value='this' />this	<option value='that' />that  </select>  <input type='submit' value='submit'></form>

mypage.php can then access that information with...

<?php  if ($_POST['something'] = 'this')  {	 echo 'this was selected'  }  else  {	 echo 'that was selected'  }?>

What your operators there! if ($_POST['something'] = 'this')is differrent than if ($_POST['something'] == 'this')
Link to comment
Share on other sites

Yes:

	<option value='this'>this</option>

Yes:

	<option value='this'>this

No!:

	<option value='this' />this

Think about it...

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...