Page 1 of 1

Moving to a new page

Posted: Wed Jan 30, 2008 2:18 pm
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! :)

Re: Moving to a new page

Posted: Wed Jan 30, 2008 3:53 pm
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.