Heres the deal... i can login, and see the
Welcome <big>" . $_SESSION['valid_user'] . "</big>
but when i try to get move on from there to the "members_only.php" page it doesnt load...
as u can see here i try to output the sessionid for testing and it comes back blank... what am i doing wrong???
<?php
//Checks for a SID in the url
//If it exists continue session
//If not, blank out the SID and start session
if (empty($_GET["SID"]))
{
session_start();
}
else
{
session_id($_GET["SID"]);
session_start();
}
//Make private
header("Cache-control: private");
//If there are variables passed from the form
if (!empty($_POST['userid']) && !empty($_POST['password']))
{
require("config.php");
//Connect to the DB
$connection = mysql_pconnect($dbip,$dbuser,$dbpass) or die (mysql_error());
$db = mysql_select_db($db, $connection);
$query = 'SELECT * FROM users WHERE uname="'.$_POST['userid'].'" AND upass="'.$_POST['password'].'" limit 1' ;
$result = mysql_query($query, $connection);
//If we have a result from the L/P
//Set the user valid for the session
if (mysql_num_rows($result) > 0)
{
// if they are a valid user
$row = mysql_fetch_array($result);
$userid = $row['uname'];
$valid_user = $userid;
$_SESSION["valid_user"] = $valid_user;
}
else
{
echo "error";
}
//Clean up memory
mysql_close($connection);
mysql_free_result($result);
}
?>
<html>
<head>
<style type="text/css">
<!--
body {
font-family: verdana,tahoma,arial;
}
#logintable {
padding: 10px;
background: rgb(195,204,225);
border: 2px solid rgb(54,45,165);
}
#loginform {
}
-->
</style>
<title>Basic Login</title>
</head>
<body>
<?
//UserID is session registered
if (isset($_SESSION['valid_user']))
{
echo "Welcome <big>" . $_SESSION['valid_user'] . "</big>";
echo "<br /><br />";
echo "<a href=\"members_only.php?SID=" . session_id(). "\">Members Page</a> | <a href=logout.php?SID=" . session_id(). ">Log Out</a><br/>";
echo "Session_id: " .session_id(); //For testing
}
else
{
//If they have just logged out or come directly to the page
if (!isset($_GET['action']) OR $_GET["action"] == "logout")
{
$message = "<big>Please Login</big>";
include("login_form.php");
}
//If they failed login
elseif (empty($valid_user) AND $_GET["action"] == "login")
{
$message = "<big>Invalid username or password</big>";
include("login_form.php");
}
else
{
echo "error";
}
}
?>