Page 1 of 1
How to post some information from a page to another?
Posted: Wed Mar 25, 2009 6:09 pm
by MicroBoy
I have some informations in a table, and I want to put them in text boxes in another page:
These informations:
I want to put here:
p.s. with my knowledge I just can put one row not all.
Re: How to post some information from a page to another?
Posted: Wed Mar 25, 2009 7:35 pm
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.
Re: How to post some information from a page to another?
Posted: Thu Mar 26, 2009 9:51 am
by MicroBoy
I want to do it using a link not a button.
Re: How to post some information from a page to another?
Posted: Thu Mar 26, 2009 9:55 am
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.
Re: How to post some information from a page to another?
Posted: Thu Mar 26, 2009 10:08 am
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.
Re: How to post some information from a page to another?
Posted: Fri Mar 27, 2009 7:22 pm
by MicroBoy
Is a bad idea to post the informations to another page using? otherpage.php?name=example&age=33&birthplace=usa etc...?
Re: How to post some information from a page to another?
Posted: Fri Mar 27, 2009 11:03 pm
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.