<div class="content clearfix">
<div class="left">
<!--info-->
</div>
<?php
if(!$_SESSION['id']):
?>
<div class="left">
<!-- Login Form -->
<form class="clearfix" action="" method="post">
<h2>Login</h2>
<?php
if($_SESSION['msg']['login-err'])
{
echo '<div class="err">'.$_SESSION['msg']['login-err'].'</div>';
unset($_SESSION['msg']['login-err']);
}
?>
<input class="field" type="text" name="username" id="username" value="User" size="23" onFocus="clearText(this)" />
<input class="field" type="password" name="password" id="password" value="Pass" size="23" onFocus="clearText(this)" />
<label><input name="rememberMe" id="rememberMe" type="checkbox" checked="checked" value="1" /> Remember me</label>开发者_JS百科;
<div class="clear"></div>
<input type="submit" name="submit" value="Login" class="bt_login" />
</form>
</div>
<div class="left right">
<!-- Register Form -->
<form action="" method="post">
<h2>Sign Up!</h2>
<?php echo $id; ?>
<?php
if($_SESSION['msg']['reg-err'])
{
echo '<div class="err">'.$_SESSION['msg']['reg-err'].'</div>';
unset($_SESSION['msg']['reg-err']);
}
if($_SESSION['msg']['reg-success'])
{
echo '<div class="success">'.$_SESSION['msg']['reg-success'].'</div>';
echo $_SESSION['id'];
unset($_SESSION['msg']['reg-success']);
}
?>
I basically want to output the version of the $_SESSION['id'];
into html upon submission so that it can be grabbed from the page as a user navigates the site. So, if a user were to go to index2.php
and logged in successfully, their ID
(the PK for their username and pass combo) would be outputted to HTML so the code could grab that if say they go to prof.php next, that session var ID from $_SESSION['id'];
could be grabbed by the page and used on prof.php
if a user were to submit the form on prof.php
Can someone please help me be able to reuse this ID over and over as pages are navigated?
Thanks
It sounds to me like you want the id
variable to be accessible across all of the pages a user visits.
That is exactly what session is designed to do. You don't want to be writing the value to the page, since unless you put it in a form, and resubmit the form, the server side will never receive it again.
Check out this reference
精彩评论