php - How to go back to previous page after successful login -
i working login system. here code redirect other page after successful login. want go previous page instead of redirect specific page.
code: login.php
<?php require_once("./include/membersite_config.php"); if(isset($_post['submitted'])) { if($fgmembersite->login()) { $fgmembersite->redirecttourl("login-home.php"); } } ?>
in previous page
add these:
session_start(); require_once("./include/membersite_config.php"); if (!$fgmembersite->checklogin()) { $_session['redirect_url'] = $_server['php_self']; header('location: login.php'); exit; }
login page
session_start(); require_once("./include/membersite_config.php"); if(isset($_post['submitted'])) { if($fgmembersite->login()) { $redirect_url = (isset($_session['redirect_url'])) ? $_session['redirect_url'] : '/'; unset($_session['redirect_url']); header("location: $redirect_url", true, 303); exit; } }
Comments
Post a Comment