|
| Web Hosting Deals | Holiday Logo Design | Webcam Chat | Website Header Templates | Register domain | Search Engine Optimisation | Web Hosting |
|
|||||||
| PHP / Perl / Java / JavaScript / CGI Tutorials PHP / Perl / Java / JavaScript / CGI Tutorials Please do not use this Forum to advertise your site or to link to tutorials. |
![]() |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
|||
|
Redirect with php
-could admin move to the correct section, seems i posted in the wrong one?..-
well, there are a few ways to do it. often you will use a header for it. but what if you want to redirect people after a script is done?. well i had this problem, and finaly found a solution. we will first need a header in the top of your page. PHP Code:
this is simple, simple set PHP Code:
now we have the header, but it doesn't run yet. what we need to do is to use PHP Code:
now it will redirect you instantly when the script is run. a test can be seen in action Here full code for that page below. PHP Code:
Last edited by zeon; 12-12-2007 at 03:33 PM. |
|
|||
|
Very nice tutorial... but i would like to ask
what if there are many headers in redirection to code let say you have header("location: index.php"); and then in the middle part you have also condition to redirect to different page header("location: redirectanotherpage.php"); so the how will i put the ob_flush(); function? shall i use it afterwards everytime i put a header location? for redirection? |
|
|||
|
@weblizzer
You need only one time,ob_start at the begging and ob_end_flush(); at end,ok so if u have many headers it's not really a problem because you need to execute if a condition is true or false. if($_POST['a'] == 'How you doing'){ header("Location: http://blah.com"); }else{ header ("Location : http://blah1.com"); } or you can have more conditions <?php if($_POST['a'] == 'Mother'){ header("Location: http://blah.com"); }elseif ($_POST['a'] == 'Father'){ header ("Location : http://blah1.com"); }elseif ($_POST['a'] == 'Sister'){ header ("Location : http://blah2.com"); }elseif ($_POST['a'] == 'Tony'){ header ("Location : http://blah3.com"); } ?> |
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|