Load a page dynamically

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
asif_phpdn
Forum Commoner
Posts: 28
Joined: Sun Aug 26, 2007 8:50 pm

Load a page dynamically

Post by asif_phpdn »

I want to load a page dynamically after click the next button. How can I do that? Any help :roll:
User avatar
luna80
Forum Newbie
Posts: 5
Joined: Sun Sep 09, 2007 1:07 am

Post 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...


asif_phpdn
Forum Commoner
Posts: 28
Joined: Sun Aug 26, 2007 8:50 pm

Post 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.
User avatar
luna80
Forum Newbie
Posts: 5
Joined: Sun Sep 09, 2007 1:07 am

Post 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:
asif_phpdn
Forum Commoner
Posts: 28
Joined: Sun Aug 26, 2007 8:50 pm

Post 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???
Post Reply