Moving to a new page

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
JeffG
Forum Commoner
Posts: 35
Joined: Wed Jan 30, 2008 1:42 pm
Location: Newbury, UK

Moving to a new page

Post by JeffG »

I am a fairly new user, but the answer to my question has to be so simple that I am almost embarrassed to be asking it. However I really don't know how to do this.

If I want to click a button on the rendered HTML page to go to a new page (passing the session), I use a Javascript function:

Code: Select all

 
<SCRIPT TYPE="text/javascript">
function page(url)
{
    document.location.href=url.concat("?", "<?php echo SID; ?>");
}
</SCRIPT>
 
and call it from the button's onclick method, thus:

Code: Select all

 
<INPUT TYPE=\"BUTTON\" VALUE=\"Cancel\" onclick=\"page('nvb_main.php')\">
 
(this is a snippet from inside a php echo).

However, if I am analysing a POST from the page in my php code, and decide I need to switch to a different page (and maybe come back after the other page has done its work), how do I do it (in php)? It has to be obvious, but I just can't see it.

For example, on a form, the user has clicked a radio button saying he wants a different address to the one given by default, and when he submits the form, I need to show him the "Find Address" form (in a different php file). I can return the information in $_SESSION variables - but how to get that form up? :?

PS: if there is something obvious I should have searched for and didn't think of, I'm sorry! :)
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: Moving to a new page

Post by Christopher »

You can do this two ways:

1. Changing the URL of the submitted form using Javascript.

2. Submitting the form to the same page and having PHP look at the value of the radio button and include() the page requested.
(#10850)
Post Reply