dimanche 31 janvier 2016

Please help me to get this PHP code work correctly

<?php include 'header.php'; 
error_reporting(E_ERROR | E_WARNING | E_PARSE | E_NOTICE);
$con = mysql_connect("localhost","root","");
$db_selected = mysql_select_db("layout",$con);
$name = $_POST['name'];
$password = $_POST['password'];
if($_POST["submit"] == "LOGIN" )
{
    $sql = "SELECT username,password from secure";
    $result = mysql_query($sql,$con);
}
while($row = mysql_fetch_array($result,MYSQL_BOTH))
{
if($row['username'] == $name and $row['password'] == $password)
   {
     echo "welcome " .$name;
   }
     else
   {
    echo "Wrong Credentials";
   }
}
?>

I'm a beginner. I wrote this PHP code for a sign in form. But it's showing "Wrong Credentials" followed by "Welcome George", even if the username and password matches. And if the username and password doesnt match it shows as "Wrong Credentials" followed by another "Wrong Credentials". Please help. Thanks in advance.

Aucun commentaire:

Enregistrer un commentaire