Hi!
I've got this checklogin.php script (below). It uses a session with no cookies.
And was wondering what the best way to access this data, from other pages, would be?
As once the user has logged in, I would like to display their username on all other pages.
Do I need to set a cookie?
Is there a way I can do it without a cookie?
Script:
$host="localhost"; // Host name
$username=""; // Mysql username
$password=""; // Mysql password
$db_name="acm_members"; // Database name
$tbl_name="members"; // Table name
// Connect to server and select databse.
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
// username and password sent from signup form
$myusername=htmlentities($_POST['myusername']);
$mypassword=htmlentities($_POST['mypassword']);
$encrypted_mypassword=md5($mypassword);
$sql="SELECT * FROM $tbl_name WHERE username='$myusername' and password='$encrypted_mypassword'";
$result=mysql_query($sql);
// Mysql_num_row is counting table row
$count=mysql_num_rows($result);
// If result matched $myusername and $mypassword, table row must be 1 row
if($count==1){
// Register $myusername, $mypassword and redirect to file "login_success.php"
session_register("myusername");
session_register("mypassword");
header("location:ACM_NEWBEG_loginsuccess.php");
}
else {
header( "location:ACM_NEWBEG_loginWRONG.php" );
}
Thanks in advance. This is really slowing me down, any help would be sweet.
Take care,
Tim