Jumping to another PHP page.

G

Guest

Guest
Hi there,
this is my first post.

Is there a command to jump to another php page ?
I encountered this problem trying to develop a sort of menu manager which should address the appropriate page for every selection made by the user.

Thanks in advance.
 
You want some javascript that'll use the onChange or similar trigger to change the document.location value which will force it to jump to another page!

In short, that's javascript, not PHP ;)
 
if your php code is in the middle of executing, i.e. it has not gotten to the user yet, there is a way. You can call the header function.

read more at:
http://www.php.net/manual/en/function.header.php

you could have the user select from a form the page he or she wants to go to, the on the page that handles the form submit, you could do some logic, then have the page return the user to a specified place.


it does seem in your post however that you want to the page to respond to a users choice for a new page directly, without the need for any other logic, at which point you should use javascript:


Code:
<form action="choosepage.php">
    <select name="goto">
        <option value="http://yoursite/page1.html">
    </select>

    ...
    ...

</form>

Code:
<?php

$goto = $_POST['goto']

$others = $_POST[...];

... perform action on $other variables


header( "Location: $goto" );

?>
 
Back
Top