I am using this line of code to check if isset is not set.
for example :
if(!isset($_REQUEST['search']))
{ }
else if(!isset($_REQUEST['submit']))
{}
I just want to know if !isset is a valid code. If not, what is the proper method? Thanks
I am using this line of code to check if isset is not set.
for example :
if(!isset($_REQUEST['search']))
{ }
else if(!isset($_REQUEST['submit']))
{}
I just want to know if !isset is a valid code. If not, what is the proper method? Thanks
 
    
    Checking a variable is set
To make it work, you pass a variable in as the only parameter to isset(), and it will return true or false depending on whether the variable is set. For example:
<?php
    $foo = 1;
    if (isset($foo)) {
        echo "Foo is set\n";
    } else {
        echo "Foo is not set\n";
    }
    if (isset($bar)) {
        echo "Bar is set\n";
    } else {
        echo "Bar is not set\n";
    }
?>
That will output "Foo is set" and "Bar is not set". Usually if you try to access a variable that isn't set, like $bar above, PHP will issue a warning that you are trying to use an unknown variable. This does not happen with isset(), which makes it a safe function to use.
 
    
    It'd fine to use !isset, no issue, but else ifif is completly wrong in your code
Approach will be:-
if(isset($_REQUEST['search'])){  // check that variable is set and have some value or not
    // variable is set and have value
}else {
   // variable is either not set or not have  value
}
 
    
    Here You are sending userName from post method.
 <?php
    if(isset($_POST['userName']))
    {
    //your code 
    header("location: dashoard.php");
    }
    else{
    // your code
    header("location: index.php");
    }
    ?>
