I made a page which check the login information if it is true or not but the code didn't work there is no errors just empty page !

<meta http-equiv="content" content="text/html" charset="UTF-8" />
<title>Login checking</title>

$username = $_POST['username'];
$password = $_POST['password'];
$md5      = md5($password);

if(empty($username) or empty($password)) {
echo "Fill all fields";
$sql = "SELECT * FROM users WHERE username='".$username."'";
$query = mysql_query($sql) or die(mysql_error());
$result = mysql_fetch_assoc($query);
if($username == $result['username'] and $md5 == $result['password']) {
$SESSION['user'] = $username;
echo "Welcome".$username;
header("Refresh: 5;index.php");
}else {
    echo "the username or the password is wrong";

Recommended Answers

All 2 Replies

There might be some errors in your script(s), but your web server is not telling you about them since most probably the display of errors is turned off. Change the following settings in your php.ini:


and restart your web server.

The errors could be in the included inc/config.php or are there simply because maybe $_POST elements do not exist. You can avoid the later by wrapping the code in an if check:

if(isset($_POST['username']) && isset($_POST['password'])) {
    $username = $_POST['username'];
    $password = $_POST['password'];
    $md5 = md5($password);

Thanks it was because of the php.ini setting as you said.The error was because I forgot to but bracket inthe end of the code ! :(

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.