html - How to keep me logged in on a php form -
i created login page php form created. whenever fill form required fields, redirected 'thank submission' page, has link 'go form'.
the problem is, when press 'go form' link, assumes not logged in anymore, , directed white page instead.
login page code:
<?php session_start(); ?> <?php if (isset($_post['submitlogin'])) { $username1= $_post['username']; $pass1= $_post['password']; if($username1==$nomepass && $pass1==$passpass) { $_session['currentuser']= $username1; echo '**html form**'; } else { //... } } ?>
form 'thank you' page:
html code within php echo ... echo ' <p> <a href="login.php">back login page</a> </p>' ;
on login form , subsequent pages using sessions, set if
statement check if session tells person has logged in set. then, redirect home page or whatever page want if logged in.
that way, if not logged in, can login otherwise, redirect you
<?php session_start(); if(isset($_session['currentuser'])){ // redirect page } else{ // else }
you create line read as:
if(isset($_session['currentuser']) && !empty($_session['currentuser']))
php html
No comments:
Post a Comment