The age old question, how do you get sessions to work with frames? I searched the forum and didn't find anything that could really help me so if anybody can that would be great.
I'm new to PHP and the world alike so I looked for a login script. I found this one:
http://php.codenewbie.com/articles/php/1482/Login_With_Sessions-Page_1.html
I did what it said and everything worked. It made sense and everything was going well until I decided to use frames. Here's where it get's hairy.
The first page is my index page. This is the code:
<?
// Login & Session example by sde
// index.php
// connect to database
include("inc/connect.php");
// include auth and nav
include("inc/auth.php");
// begin content
include("inc/nav.php");
// close mysql connection
mysql_close();
?>
<body bgcolor="#000000" text="#FFFFFF" link="#0000FF" vlink="#800080" alink="#FF0000">
Well it can't authenticate obviously because no session has previously been created so it executes the auth.php which is below:
<html>
<head>
<title>SMC3D Login</title>
</head>
<?
// 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 user_table
where username='" . $SESSION['username'] . "' and password='" . $SESSION['password'] . "'");
// retrieve number of rows resulted
$num=mysql_num_rows($result);
// print login form and exit if failed.
if($num < 1){
echo "<br><br><br><br><br><center><b>Please login to access the SM3CD:</b><br><br>
<form method=POST action=home.php>
Username: <input type=text name=\"username\"><br>
Password: <input type=password name=\"password\"><br><br>
<input type=submit value=Login>
</center></form>";
exit;
}
?>
</html>
Ok, so now after they have logged in and a session is started it takes them to home.php which is actually a framed page.
<head>
<html>
<frameset rows="10%,90%">
<frame src="header.html" noresize>
<frameset cols="15%,85%">
<frame src="blah.php" noresize>
<frame src="index.php">
</frameset>
</frameset>
</head>
</html>
It's basically your standard three framed page. It has a header on top, a menu on the left hand side, and then the body taking up the center and right. Well, instead of the center and right frame displaying index.php (which is the first code I posted) it takes me back to the authentication page and wants me to login. Then it just keeps doing that and the frames keep building up inside of each other. I know there's got to be a fix I'm just not sure what to do from here. Does anybody have any ideas? Your help is appreciated. Thanks
CJ