How to post some information from a page to another?

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
MicroBoy
Forum Contributor
Posts: 112
Joined: Sat Mar 14, 2009 5:16 pm

How to post some information from a page to another?

Post by MicroBoy »

I have some informations in a table, and I want to put them in text boxes in another page:

These informations:
Image

I want to put here:
Image

p.s. with my knowledge I just can put one row not all.
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Re: How to post some information from a page to another?

Post by califdon »

The two general ways are (1) if the data is in an HTML form and the page you want to use the data is the action= page, you just read them from the $_POST array, using the name= attribute of the form element as the index; (2) if you need the data on a different (maybe later) page, you need to store them in $_SESSION variables.
MicroBoy
Forum Contributor
Posts: 112
Joined: Sat Mar 14, 2009 5:16 pm

Re: How to post some information from a page to another?

Post by MicroBoy »

I want to do it using a link not a button.
mattpointblank
Forum Contributor
Posts: 304
Joined: Tue Dec 23, 2008 6:29 am

Re: How to post some information from a page to another?

Post by mattpointblank »

Make your link something like:

showdata.php?id=123

then on the page, query your database for record #123 and populate the forms with the relevant info.
MicroBoy
Forum Contributor
Posts: 112
Joined: Sat Mar 14, 2009 5:16 pm

Re: How to post some information from a page to another?

Post by MicroBoy »

mattpointblank wrote:Make your link something like:

showdata.php?id=123

then on the page, query your database for record #123 and populate the forms with the relevant info.
I tried that, but just the information of ID goes to the other page.
MicroBoy
Forum Contributor
Posts: 112
Joined: Sat Mar 14, 2009 5:16 pm

Re: How to post some information from a page to another?

Post by MicroBoy »

Is a bad idea to post the informations to another page using? otherpage.php?name=example&age=33&birthplace=usa etc...?
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Re: How to post some information from a page to another?

Post by califdon »

MicroBoy wrote:Is a bad idea to post the informations to another page using? otherpage.php?name=example&age=33&birthplace=usa etc...?
Whether it's a bad idea depends on what kind of information it is. If it is confidential data or anything you wouldn't want someone to know, it's certainly a bad idea, since it is easy to see in the URL and someone can try other data to get other responses from the server.

I usually try to avoid using the GET method and I prefer to use a form and the POST method, although there are many situations in which it is simpler to use GET. Or, as I told you before, you can use SESSION variables. It all depends on what you are trying to do. Look at how other scripts do these things.
Post Reply