Page 1 of 1

Load a page dynamically

Posted: Sun Sep 09, 2007 10:28 am
by asif_phpdn
I want to load a page dynamically after click the next button. How can I do that? Any help :roll:

Posted: Sun Sep 09, 2007 10:57 am
by luna80
I think there are more than a solution...

One possiblity is that when you click the button you always call the same page with a parameter that tell which page you want to call and in this page you put a redirect line.
Supposing you pass the parameter "page_name" with the GET method, in the called page you will have something like this:

Code: Select all

header("location: ".$_GET['page_name']);
Another possibility is to manage the click button with a javascript function that load the page depending a parameter. In this case, an example can be:

Code: Select all

function load_page(page_name)
{
document.location.href=page_name;
}
and in the form the button that call this funtion is something like this code:

Code: Select all

<input type="button" id="btn_load" onclick="load_page('page_name');">
I hope you understand me...I don't speak english very well...



Posted: Sun Sep 09, 2007 11:34 am
by asif_phpdn
luna80 wrote:I think there are more than a solution...

One possiblity is that when you click the button you always call the same page with a parameter that tell which page you want to call and in this page you put a redirect line.
Supposing you pass the parameter "page_name" with the GET method, in the called page you will have something like this:

Code: Select all

header("location: ".$_GET['page_name']);
Another possibility is to manage the click button with a javascript function that load the page depending a parameter. In this case, an example can be:

Code: Select all

function load_page(page_name)
{
document.location.href=page_name;
}
and in the form the button that call this funtion is something like this code:

Code: Select all

<input type="button" id="btn_load" onclick="load_page('page_name');">
I hope you understand me...I don't speak english very well...

Thanks luna80 for your help. But.....

Do you mean include a file or page in your first point???

Anyway I think your third point is easy for me.

My mother language is not English.

So I'm what you are.

Posted: Sun Sep 09, 2007 12:08 pm
by luna80
asif_phpdn wrote:
Thanks luna80 for your help. But.....

Do you mean include a file or page in your first point???
no...

in the action of the button's form you put a page, in this page you put the code I show you in my first response. I show you the complete code:

example for the page with the button:

Code: Select all

<form id="form1" method="post" action="page.php">
<input type="text" id="page_to_load">
<input type="submit" id="btn" value="load page">
</form>
page.php:

Code: Select all

header("location: ".$_POST["page_to_load"]);

I hope this example help you to better understand :wink:

Posted: Sun Sep 09, 2007 7:58 pm
by asif_phpdn
How far I could understand is you need a page that already exists. But If I want a page load reading the content of a file then waht to do???