Thanks for the above responses guys....
That code looks like its fine....
Just gonna paste my other small prob from another forum...
Take a look of you got time, cheers
My current logon does work.
I have a DB USERS
User_ID
Username
Pasword
The login page is here
http://art.uk-graffiti.co.uk/login.php
User = please
pass = help
Try loggin on with the wrong user/pass and with the above
The correct error messages appear. But when i log in successfuly and click "check status" nothing appears.
here is the code for the login:
if (!isset($username) || !isset($password)) {
header( "Location: [url]http://art.uk-graffiti.co.uk/logedin.php[/url]" );
}
elseif (empty($username) || empty($password)) {
header( "Location: [url]http://art.uk-graffiti.co.uk/logedin.php[/url]" );
}
else{
$user = addslashes($_POST['username']);
$pass = md5($_POST['password']);
$dbHost = "localhost";
$dbUser = "ukart";
$dbPass = "***";
$dbDatabase = "ukart";
$db = mysql_connect("$dbHost", "$dbUser", "$dbPass") or die ("Error connecting to database.");
mysql_select_db("$dbDatabase", $db) or die ("Couldn't select the database.");
$result=mysql_query("select * from users where username='$user' AND password='$pass'", $db);
$rowCheck = mysql_num_rows($result);
if($rowCheck > 0){
while($row = mysql_fetch_array($result)){
session_start();
session_register('username');
echo 'Success!';
header( "Location: index.php" );
}
}
else {
echo 'Incorrect login name or password. Please try again.';
}
}
?>
here is code for "checkstatus"
?php
session_start();
if(session_is_registered('username')){
echo 'Welcome, you are still logged in.';
}
else{
header( "Location: [url]http://art.uk-graffiti.co.uk/login.php[/url]" );
}
?>
I really appreciate the help and any tips on improvements