Jump to content

[SOLVED] isset problem


williamZanelli

Recommended Posts

Hi guys,

 

I have a drop down list, something like

<select name="my_team">
<option></option>
		<option>One </option>
		   <option >Two</option>
		  
</select>

 

Now, if the user selects the blank option, what would the following statement return

 

if(isset($_POST["my_team"]))

 

I'm not entirely sure how isset is work, hence this issue.

 

Thanks for your help in advance,

 

Will

Link to comment
https://forums.phpfreaks.com/topic/133085-solved-isset-problem/
Share on other sites

isset does as it sounds, if the variable has been used, it's set.

no matter wut the value is, null, false, ""

 

u use it for checking the existance of the variable

such as checkboxes, they dun return anything if not checked, and return value if it is checked

 

if(isset($_POST['checkbox']) $ans='yes';
else $ans='no';

 

a simple way if ya doing all in one forms/php scripts, is checking $_POST.

 

if(isset($_POST)) { // Process Form here }
// Show form here

 

empty can be null, "", false, 0, array() (empty array), or '0'

we not checking existance of a variable, but checking if it has content

 

if(empty($username)) { die('Empty username"); }

 

Link to comment
https://forums.phpfreaks.com/topic/133085-solved-isset-problem/#findComment-692118
Share on other sites

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.