Hello Everyone,
I’m having an issue with my code. I’m basically getting a white screen as soon as it has run. I’ve tried ways of getting it to display an error message but to no avail, no matter what I try to get an error message to display. I’ve also tried to correct the problem but to no avail either. here is the code:
[php]<?php
// dBase file
include “DBC.php”;
mysql_ping();
if (!$_POST[“UserName”] || !$_POST[“Password”])
{
die(“You need to provide a username and password.”);
}
// Create query
$username = $_POST[“UserName”];
$username = mysql_real_escape_string($username);
$password = $_POST[“Password”];
$password = mysql_real_escape_string($password);
mysql_select_db(“jamesl_bromleyduties”);
$q = “SELECT MemberID FROM Members WHERE MemberUsername = ‘$username’ AND MemberPassword = ‘$password’”;
// Run query
$r = mysql_query($q) or die(mysql_error());
$count = mysql_num_rows($r) or die(mysql_error());
if ( !$count == 1 )
{
// Login not successful
die(“Sorry, could not log you in. Wrong login information.”);
} else
{
$r = mysql_query($q) or die(mysql_error());
$id = mysql_result($r);
setcookie(“User”, $id, time()+3600);
Header(“Location: main.php”) or die(mysql_error());
}
?>[/php]
After some error testing I located the issue at the [php]Header(“Location: main.php”)[/php]. I’ve checked main.php to see if there are any errors with that, but that is working fine.
The code above does register the cookie and allows me to access controlled page but it will not redirect me to the page: main.php. Just gives me a blank white screen.
Hope someone can help me, if more detail is required please let me know
Regards
James