DeepakJ Posted August 1, 2007 Share Posted August 1, 2007 Can someone link me to a tut or a site or just explain how you would do this. I understand the header thing but wanna redirect to different pages based on values entered on the previous page. Quote Link to comment https://forums.phpfreaks.com/topic/62908-solved-php-conditional-redirection/ Share on other sites More sharing options...
almightyegg Posted August 1, 2007 Share Posted August 1, 2007 basically you send them to a page, in this instance we'll call it redirect.php if($variable1 == value){ header("Location: page1.php"); }elseif($variable2 == value2){ header("Location: page2.php"); }else{ echo "Error!"; } If you told me what information was being bought to the page and how (by form, cookies etc..) I could be of more help Quote Link to comment https://forums.phpfreaks.com/topic/62908-solved-php-conditional-redirection/#findComment-313164 Share on other sites More sharing options...
DeepakJ Posted August 1, 2007 Author Share Posted August 1, 2007 if ($_GET['verif']){ header("Location: trueverif.html"); } elseif ($_GET['sinput']){ header("Location: truesinput.html"); } elseif ($_GET['linput']){ header("Location: truelinput.html"); } elseif ($_GET['vdata']){ header("Location: trueviewdata.html"); } elseif ($_GET['rdata']){ header("Location: reportdata.php"); } Why doesn't this code work then? Quote Link to comment https://forums.phpfreaks.com/topic/62908-solved-php-conditional-redirection/#findComment-313227 Share on other sites More sharing options...
a1phanumeric Posted August 1, 2007 Share Posted August 1, 2007 Can you post an example URL to that page (with the query string). Ed. Quote Link to comment https://forums.phpfreaks.com/topic/62908-solved-php-conditional-redirection/#findComment-313231 Share on other sites More sharing options...
ViN86 Posted August 1, 2007 Share Posted August 1, 2007 i just use javascript.... <?php if (condition){ echo '<script>window.location = "page1.php"</script>'; } else if (condition2) { echo '<script>window.location = "page2.php"</script>'; } else { echo '<script>window.location = "page3.php"</script>'; } ?> yours would be if ($_GET['verif']){ echo '<script>window.location = "trueverif.html"</script>'; } elseif ($_GET['sinput']){ echo '<script>window.location = "truesinput.html"</script>'; } elseif ($_GET['linput']){ echo '<script>window.location = "truelinput.html"</script>'; } elseif ($_GET['vdata']){ echo '<script>window.location = "trueviewdata.html"</script>'; } elseif ($_GET['rdata']){ echo '<script>window.location = "reportdata.html"</script>'; } Quote Link to comment https://forums.phpfreaks.com/topic/62908-solved-php-conditional-redirection/#findComment-313241 Share on other sites More sharing options...
a1phanumeric Posted August 1, 2007 Share Posted August 1, 2007 Change your javascript so it includes the querystring: <?php if (condition){ echo '<script>window.location = "page1.php?verif"</script>'; } else if (condition2) { echo '<script>window.location = "page2.php?sinput"</script>'; } else { echo '<script>window.location = "page3.php?linput"</script>'; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/62908-solved-php-conditional-redirection/#findComment-313253 Share on other sites More sharing options...
DeepakJ Posted August 1, 2007 Author Share Posted August 1, 2007 This is what accesses it: <html><head><title>AlibreCam Verification System</title></head> <center> <input type="submit" value="Verification" name = "verif"> <input type="submit" value="Sales Input" name = "sinput"> <input type="submit" value="License Input" name = "linput"> <input type="submit" value="View Data" name = "vdata"> <input type="submit" value="Report Data" name = "rdata"> </center> </html> Quote Link to comment https://forums.phpfreaks.com/topic/62908-solved-php-conditional-redirection/#findComment-313255 Share on other sites More sharing options...
thefortrees Posted August 1, 2007 Share Posted August 1, 2007 read up on header(). http://us3.php.net/manual/en/function.header.php You can not output ANYTHING (HTML, PHP print statements, etc) to the browser before you redirect with header(). If you want to redirect with it, make sure that it comes before any output to the browser. Quote Link to comment https://forums.phpfreaks.com/topic/62908-solved-php-conditional-redirection/#findComment-313257 Share on other sites More sharing options...
DeepakJ Posted August 1, 2007 Author Share Posted August 1, 2007 Vin86 your method worked but it changed only the frame. How would I make it so that it would change the whole page Quote Link to comment https://forums.phpfreaks.com/topic/62908-solved-php-conditional-redirection/#findComment-313258 Share on other sites More sharing options...
ViN86 Posted August 2, 2007 Share Posted August 2, 2007 thx a1pha for the correction. Quote Link to comment https://forums.phpfreaks.com/topic/62908-solved-php-conditional-redirection/#findComment-313976 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.