-1

THIS is the PHP code m using for checking the values

if($uname==$row['username']) {

    if($uname=='' || $pass=='') {       

        header("Location:login.html?id=Some fields are empty");

    } else if($uname==$row['username'] && $pass==$row['password']) {

        header("Location:1.html?id=$uname");

    } else {   

        // **HERE I AM REDIRECTING TO THE LOGIN PAGE AND SENDING ERROR MESSAGE AS ID**
        header("Location:login.html?id=Incorrect Password");    
    }       
}

In the HTML part I included this to show the error message

<?php
if(isset($_GET['id'])) 
{
     echo $_GET['id'];
}
?>

However NOTHING is getting printed

6
  • 6
    Make sure your server is set to parse HTML as PHP... CHeck out the source, of the page served, I'm sure you can see the PHP in plain.
    – Salketer
    Oct 16, 2013 at 14:55
  • 1
    Do a view source. you'll see your PHP code in the browser, because you're serving it up as a .html file, which is generally NOT processed by PHP on the server. Rename to .php, update you forms, and try again.
    – Marc B
    Oct 16, 2013 at 14:57
  • Am I being naive, or don't you have to have php inside .php files?
    – Aleski
    Oct 16, 2013 at 14:59
  • @Aleski: PHP is not necessarily limited to *.php files Oct 16, 2013 at 15:00
  • Unless you specifically tell the server to treat html files as php in the httpd.conf or .htaccess
    – aynber
    Oct 16, 2013 at 15:01

2 Answers 2

0

As mentioned in the comments, make sure that the server is set to parse .html file as PHP. See Server not parsing .html as PHP

The other option is to change your login.html to be login.php and go from there.

0

you can use php filters to check correctly if the values are set or not like the following :

filter_has_var(INPUT_GET , 'id');

this function returns true or false

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.