I want to redirect the previous page after the log in form submit and form processing. Actually i have code as below, but it shows a error.....plz help me. I have a log in page and i use this code to fine current page. <input name="last_url" type="hidden" value="<?=$_SERVER['HTTP_REFERER']?>"/> and after submit the log in page i use this code for form processing. <?php session_start(); require("config/common_db.inc"); db_connect(); $Last_Url=$_GET["last_url"]; //$_SESSION=$Last_Url; $msgEmail=''; if (...cument to handle the request. Plz help me.
Ok, your header is wrong. Should be header("Location: ".$Last_Url); You are actualy redirecting to url "echo $Last_Url" Hope that helps. You should really fix your mysql, it is very easy to mysql injection on your site. Make sure you filter your input to your mysql. $username = addslashes ($_POST['MemberID']) $password = addslashes($_POST['Password']) If you really want to be good, make sure that $username is only numbers.
Thanks For your reply. But it does not work properly. Actually it stay on same page i think it has a <input name="last_url" type="hidden" value="<?=$_SERVER['HTTP_REFERER']?>"/> this coding problem. Help me.
Before you submit your login page, check the source code to see if value equals to the correct page. HTTP_REFERER is not good anyways. From the php site: The address of the page (if any) which referred the user agent to the current page. This is set by the user agent. Not all user agents will set this, and some provide the ability to modify HTTP_REFERER as a feature. In short, it cannot really be trusted.
Your redirect error is because of "echo" word in the header command. Remove echo word. use: header("location: $last_url"); Use the " sign instead of ' sign and it should work. Thanks