Jump to content

So Simple - Isset


magnetica

Recommended Posts

The code below simply checks if  the variable $name is set and returns a string accordingly.

 

But it works if the $name is set but if it is not then is doesn't?

 

Why is this? Whats wrong with this?

 

 

$name = $_POST['name'];
if ( !isset($name) )
   {
       echo "Not Set";
   }
   else
   {
       echo $name;
   }

Link to comment
https://forums.phpfreaks.com/topic/40842-so-simple-isset/
Share on other sites

That depends.

I suppose you have a form that contains a text field named "name". By checking if it is not set, you are checking if the form was submitted or did someone access directly to the file processing the form. By checking if it is empty, you are checking if the form was submitted and someone didn't fill in the "name" field.

 

Orio.

Link to comment
https://forums.phpfreaks.com/topic/40842-so-simple-isset/#findComment-197766
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.