I am a little confused on how to keep a variable registered on more than one
page.  For example you log into a page which queries the database.  Form
code is as follows...
<?php
session_start();
?>
<html>
<body bgcolor="#FFFFFF" text="#000000">
<?php print(session_id()); ?>
<form name="login" method="post" action="auth_done.php">
User Name:
  <input type="text" name="u_name" maxlength="25">
Password:
  <input type="password" name="p_word" maxlength="25">
<input type="submit" name="login" value="login">
</form>
</body>
</html>
The auth_done.php then checks to see if the user entered anything for the
username and password and if it doesnt it will re-direct them to the login
page.  If the un and pw has been entered it will then query the database for
a valid entry, code is as follows...
<?php
if ((!$u_name) || (!$p_word)){
 header("Location: index.php");
 exit;
}
$db_name = "authentication";
$table_name = "accounts";
$connection = @mysql_connect("localhost","","") or die("Could not connect to
Database, please try again later");
$db = @mysql_select_db($db_name, $connection) or die("Could not select
Database, please try again later");
$sql = "SELECT * from $table_name
    WHERE u_name = \"$u_name\" AND p_wordd = password(\"$p_word\")";
$result = @mysql_query($sql,$connection) or die("Couldn't execute query");
$num = mysql_numrows($result);
if ($num !=0) {
$msg = "<p class=\"content\">You have been authorized to make changes to the
web site.</p>";
session_is_registered('u_name');
session_is_registered('p_word');
session_start();
} else {
header("Location: index.php");
exit;
}
?>
<html>
<body bgcolor="#FFFFFF" text="#000000">
<?php echo $msg; ?><br>
<?php print (session_id()); ?><br>
<?php echo $u_name; ?><br>
<?php echo $p_word; ?><br>
<?php print (session_is_registered('u_name')); ?><br>
<?php print (session_is_registered('p_word')); ?><br>
<a href="edit.php">edit pages</a>
</body>
</html>
The problem I am having is if the user clicks the link for edit.php the
session variables "u_name" and "p_word" are not being passed and I can't do
any other checking with out that.  Please help, good tutorials on this are
very appreciated!
Thanks in advance,
Jas



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to