Global Value in new page
Posted: Sun Feb 24, 2008 8:30 pm
I have a mysql db that will authenticate a user to a website. The problem that I am running into is that I would like to display the user name on another page but I am having trouble with the global values. The below code labeled connect.php and login.php will connect to the DB and authenticate but I need a little guidance with the last step name tempager.php. Thanks in advance.
connect.php
login.php
tempager.php
The code written the way it is will constantly request a login and password.
connect.php
Code: Select all
<?php
$connect = mysql_connect ('localhost','dbaccess','only');
mysql_select_db('backuplog', $connect);
?>
Code: Select all
<?php
include "connect.php";
$sql = "select name from user where login='$id' and password='$password' ";
$result = mysql_query ($sql, $connect);
$row = mysql_fetch_array($result);
$username = $row[name];
if($row)
{
echo ("
<body bgcolor='white'>
Name: <font color='red'> $username</font>
</body>
<br><br><meta http-equiv='refresh' content='2; url=tempager.php'>
");
}
else {
echo ("
<html>
<head><title></title>
<meta http-equiv='refresh' content='0; url=login.html'>
</head>
<body bgcolor='white'>
</body>
</html>
");
}
?>
Code: Select all
<?php
echo include "login.php";
echo ("
Name: <font color='red> $username</font>
");
?>