Jump to content

<option> And Php?


EmperorZenos
 Share

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...

Edited by Synook
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...