My PHP code gives an error. My idea was to just check if the username and password exists in the database and then redirect it to the URL.
enter code hereI have two pages created. One is index and other is redirect. Redirect code is giving problem.
<!DOCTYPE html>
<html>
<body>
<?php
//echo $_POST['uname'];
//echo $_REQUEST['uname'];
$uname=$_POST['uname'];
$pwd=$_POST['pwd'];
//echo $_POST['pwd'];
//echo $_REQUEST['pwd'];
//echo $uname;
//echo $pwd;
$con = mysql_connect("localhost","root","root");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
$db_found=mysql_select_db("sn", $con);
//$result = mysql_query("SELECT fname,password FROM udata");
if ($db_found)
{
$result = mysql_query("SELECT fname,password FROM udata");
while ( $db_field = mysql_fetch_assoc($result) )
{
if ($db_field['uname']==$uname && $db_field['password']==$pwd)
header( 'Location: www.youtube.com' ) ;
/*print $db_field['fname'] . "<BR>";
print $db_field['lname'] . "<BR>";
print $db_field['uname'] . "<BR>";
print $db_field['password'] . "<BR>";
*/
}
mysql_close($con);
}
else
{
print "Database NOT Found ";
mysql_close($db_handle);
}
?>
</body>
</html>
Please help me with this.