I am very new to PHP so please forgive my ignorance. I have been reading posts for the last while and have set up a registration page that encrypts the password with sha1. This page works. My problem is when I try to log in.
I have a simply form that submits to session.php. When I process the form, if the password it incorrect my “print” command works. If the password is correct, the “session.php” page loads blank and the header command does not redirct.
I have tried trouble shooting by replacing the header command with a “print” command and that works. I have tried the header command on it’s own in a blank page and it works. It just doesn’t seem to work on my page.
Thank you for any help you can give me.
My code is placed at the top of the page and it is as follows:
<?php
session_start();
require (‘pconnect.php’);
$username = $_POST[‘username’];
$password = $
$select_query = sprintf(“SELECT * FROM users WHERE username = ‘$username’ and password = sha1(‘$password’)”);
$select_result = mysql_query($select_query);
if (!$select_result) {
$message = ‘Invalid query: ‘ . mysql_error() . “n”;
$message .= ‘Whole query: ‘ . $select_query;
die($message);
}
if (mysql_num_rows($select_result) == 1) {
$row = mysql_fetch_assoc($select_result);
$_SESSION[‘username’] = $row[‘password’];
header (‘Location: TenantBasicInfo.php’);
} else {
Print “User was not found. Check your username and password and try again or register if you haven’t!”;
}
?>