Heba Posted February 28, 2006 Share Posted February 28, 2006 [!--fonto:Century Gothic--][span style=\"font-family:Century Gothic\"][!--/fonto--]Hi thereI've learnt that [b]header('Location: URL'');[/b]is like [b]Response.redirect [/b] in ASPSo i tried to do this code but it doesnt work ... [code]<?php if(isset($_POST['submit']) && $_POST['submit'] == 'Submit') //if form has been submitted{ $url = "http://localhost/Warehouse_Services_Operations_System/main.php"; $denied = ""; $name = $_POST['name']; $pass = $_POST['pass']; if ($name == "Heba" && $pass == "123") { header('Location: '.$url.''); /* Redirect browser */ exit; } else { $denied = "Sorry. You are not authorized to access this page<br>Go <a href='index.php' onclick='history.go(-1);return false'> Back </a>"; }}?><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html><head><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><title>SYS</title>.............<body><?phpif(!empty($denied)){echo $denied;}?>............</body></html>[/code]Can someone please enlighten me![!--fontc--][/span][!--/fontc--] Quote Link to comment https://forums.phpfreaks.com/topic/3739-redirect-in-php/ Share on other sites More sharing options...
loki_racer Posted February 28, 2006 Share Posted February 28, 2006 Try this. I think that header() won't let you use variables inside its ( ).[code]<?php if(isset($_POST['submit']) && $_POST['submit'] == 'Submit') //if form has been submitted{ $denied = ""; $name = $_POST['name']; $pass = $_POST['pass']; if ($name == "Heba" && $pass == "123") { header("Location: Warehouse_Services_Operations_System/main.php"); /* Redirect browser */ exit; } else { $denied = "Sorry. You are not authorized to access this page<br>Go <a href='index.php' onclick='history.go(-1);return false'> Back </a>"; }}?><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html><head><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><title>SYS</title>.............<body><?phpif(!empty($denied)){echo $denied;}?>............</body></html>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/3739-redirect-in-php/#findComment-13050 Share on other sites More sharing options...
kenrbnsn Posted February 28, 2006 Share Posted February 28, 2006 No, you can use variable within a header() function.To the OP ... what indications do you get that it doesn't work? Errors? Ken Quote Link to comment https://forums.phpfreaks.com/topic/3739-redirect-in-php/#findComment-13065 Share on other sites More sharing options...
Heba Posted March 1, 2006 Author Share Posted March 1, 2006 ok when i did that it worked but it gives me an empty window with no messages! Quote Link to comment https://forums.phpfreaks.com/topic/3739-redirect-in-php/#findComment-13209 Share on other sites More sharing options...
Caesar Posted March 1, 2006 Share Posted March 1, 2006 Error reporting may be disabled in your php.ini file.PM me and link me...and I will solve all your problems. :-P Quote Link to comment https://forums.phpfreaks.com/topic/3739-redirect-in-php/#findComment-13211 Share on other sites More sharing options...
Heba Posted March 1, 2006 Author Share Posted March 1, 2006 SOLVED :DThank you all Quote Link to comment https://forums.phpfreaks.com/topic/3739-redirect-in-php/#findComment-13220 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.