Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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