What am I doing wrong here? I have a login form that visitors enter their
"use"name and "use_psswrd" in to log in...the form action is this code:
========<SNIP 1>==========
<?
session_start();
if ($_REQUEST[use_name] && $_REQUEST[use_psswrd])
{
$connection = mysql_connect("SERVER","USER","PASS") or die
("Couldn't make connection.");
$db = mysql_select_db("DB", $connection) or die ("Couldn't select
the database.");
$sql = "select * from TABLE where use_name = '$_REQUEST[use_name]'
and use_psswrd = '$_REQUEST[use_psswrd]'";
$sql_result = mysql_query($sql) or die ("Couldn't execute query.");
if (mysql_num_rows($sql_result) >0 )
{
list($valid_id, $valid_user) = mysql_fetch_row($sql_result);
session_register("valid_id", "valid_user");
// echo "$valid_id, $valid_user";
header("Location:
modify_profile.php?uid=$valid_id&un=$valid_user");
}
else
{
header("Location: profile_login.php");
exit;
}
}
mysql_free_result($sql_result);
mysql_close($connection);
?>
======<END SNIP 1>=======
That page is supposed to register a session that holds both the "valid_id"
and "valid_user" variables and continue on the the next page (which it
does) - BUT once the user gets to the next page:
=======<SNIP 2>========
<?
session_start();
if (isset("valid_id"))
{
echo "$_SESSION[valid_id]<P>";
}
else
{
echo "DUMBASS!";
}
?>
======<END SNIP 2>=======
Nothing gets displayed.....Am I not setting or requesting them correctly??
The one thing I cant understand is why the URI now reflects the user is
logged in: (modify_profile.php?uid=1&un=jerry)
TIA,
Jay
- Re: [PHP] PHP Login Sessions Jay Fitzgerald