tipalm73
June 14th, 2007, 05:56 PM
I have managed, through tutorials, to get a skeleton website up using php and mysql.
You can add a new user, login to home page see links and log out. The problem is once you get to home page any link you click other then logout forces you to log in again. I want the initial login to carry over to the internal site. The URL is tipalm.mine.nu... please be gentle =]
I think the problem is auth.php doesnt check if you are allready logged in and it is called on each page. Here is a link to the tutorial http://php.codenewbie.com/articles/p...ns-Page_1.html and the auth.php code:
<?
// Login & Session example by sde
// auth.php
// start session
#session_start();
// convert username and password from _POST or _SESSION
if($_POST){
$_SESSION['username']=$_POST["username"];
$_SESSION['password']=$_POST["password"];
}
// query for a user/pass match
$result=mysql_query("select * from users
where username='" . $_SESSION['username'] . "' and password='" . $_SESSION['p$
// retrieve number of rows resulted
$num=mysql_num_rows($result);
// print login form and exit if failed.
if($num < 1){
echo "You are not authenticated. Please login.<br><br>
<form method=POST action=index.php>
User name: <input type=text name=\"username\"><br><br>
Password: <input type=password name=\"password\"><br><br>
<a href=/adduser.php>New User</a><br>
<br><input type=submit value='Log In' >
</form>";
exit;
}
?>
Thanks in advanced =]
You can add a new user, login to home page see links and log out. The problem is once you get to home page any link you click other then logout forces you to log in again. I want the initial login to carry over to the internal site. The URL is tipalm.mine.nu... please be gentle =]
I think the problem is auth.php doesnt check if you are allready logged in and it is called on each page. Here is a link to the tutorial http://php.codenewbie.com/articles/p...ns-Page_1.html and the auth.php code:
<?
// Login & Session example by sde
// auth.php
// start session
#session_start();
// convert username and password from _POST or _SESSION
if($_POST){
$_SESSION['username']=$_POST["username"];
$_SESSION['password']=$_POST["password"];
}
// query for a user/pass match
$result=mysql_query("select * from users
where username='" . $_SESSION['username'] . "' and password='" . $_SESSION['p$
// retrieve number of rows resulted
$num=mysql_num_rows($result);
// print login form and exit if failed.
if($num < 1){
echo "You are not authenticated. Please login.<br><br>
<form method=POST action=index.php>
User name: <input type=text name=\"username\"><br><br>
Password: <input type=password name=\"password\"><br><br>
<a href=/adduser.php>New User</a><br>
<br><input type=submit value='Log In' >
</form>";
exit;
}
?>
Thanks in advanced =]