Jump to content

Isset always true ?


Rommeo

Recommended Posts

Hi

 

i have a login form and a logincheck.php file.

when i enter directly to logincheck.php the function "isset" gives me true which is wrong. I think the way i m using for isset is true

 

$username = $_POST['form_username'];
	$username = str_replace("_", "", $username);
	$username = trim($username);
$usernameset = isset($username);
echo "username = $username Username exist = $usernameset";

and the output is

1

Is there anything that i need to use additionaly with isset ? Is there any other option ?

 

I will be glad if anyone can help.

Thanx in advance.

 

( as far as i know isset gives true (1) when it's set otherwise zero. )

Link to comment
Share on other sites

When using isset never do:

$var  = $_POST['var'];

if(isset($var))
{
   // do something
}

As that will always evaluate to true. You should do this instead:

if(isset($_POST['var']) && !empty($_POST['var']))
{
    $var  = $_POST['var'];
    // do something
}

Link to comment
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.