-1

<?php 
$conn = mysql_connect('localhost','root','') or die("could not connect to server".mysql_error());
mysql_select_db("khader",$conn) or die ("could not connect to database".mysql_error());
if(isset($_POST['submit']))
{
$Usname = mysql_escape_string($_POST['Uname']);
$Pd = mysql_escape_string($_POST['psd']);
if(!$_POST['Uname']||!$_POST['psd']);
{
echo "please fill the required fields before you login" ;
exit();
}
$query = <<<EOF
select * from person where 'uname' = '$Usname' and 'pswd' = '$pd';
EOF;
$query_result= mysql_query($query) or die ("cannot be connected".mysql_error());
if(mysql_num_rows($query)>0)
{
header("logged.php");
}
else
{
echo "wrong username and password" ;
}
mysql_close($conn) or die ("disconnect failed.".mysql_error());
?>

this is the program that throws the error !! i've tried most of things i know to correct it but there is know improvement at all .. please help me and thanks alot !!!

Khader
  • 305
  • 1
  • 4
  • 10

1 Answers1

1

You need to close all if's:

<?php 
$conn = mysql_connect('localhost','root','') or die("could not connect to server".mysql_error());
mysql_select_db("khader",$conn) or die ("could not connect to database".mysql_error());
if(isset($_POST['submit']))
{
$Usname = mysql_escape_string($_POST['Uname']);
$Pd = mysql_escape_string($_POST['psd']);
if(!$_POST['Uname']||!$_POST['psd']);
{
echo "please fill the required fields before you login" ;
exit();
}
$query = <<<EOF
select * from person where 'uname' = '$Usname' and 'pswd' = '$pd';
EOF;
$query_result= mysql_query($query) or die ("cannot be connected".mysql_error());
if(mysql_num_rows($query)>0)
{
header("logged.php");
}
else
{
echo "wrong username and password" ;
}
mysql_close($conn) or die ("disconnect failed.".mysql_error());
} // <-- you forgot this
?>
Florian
  • 2,796
  • 1
  • 15
  • 25