PHP form which takes the info and displays it on a seperate page?

Associate
Joined
17 Mar 2004
Posts
1,562
I'm looking to have a basic form on my website, which when submitted posts the info on another page which refreshes every 20-30 seconds or so.

I know how to create the form, and I know how to get the page refreshing, i'm just stuck on how to get the data to the other page?

Both pages would be on the same server/domain btw.

Thanks in advance.
 
Look into using POST and GET for sending info to the other page.

POST send the information to the server hidden in the background.
GET sends the information in the URL

http://www.w3schools.com/php/php_post.asp
http://www.w3schools.com/php/php_get.asp

EDIT: Were you going to save the information sent to a file or database to be used at a later time, or were you just going to show the user a summary of the information they just input? Im guessing that if you are refreshing the page every 20 seconds or so you will want to save the data on the server in a file or database, if you dont then the page refreshing will keep asking for the data to be resent if you use POST, or wont change if you use GET (since the information will be the same since th URL will stay the same).

I would look into AJAX instead of refreshing if i were you. Ajax can access a web page in the background and insert the returning web page back into a <div> on your open web page without refreshing it.

So for example, you would submit the data using your form page and it would be saved in a file, the viewing page would then load up and show the contents of that file. The contents would then refresh every 20 seconds or so depending on what you specify it as using AJAX.

Hope that helps :)
 
Last edited:
Sorry, didn't make myself clear.

The person submitting the form wouldn't see the responses - they'd be on the same page and just see a message saying "Your message has been sent".

No need to store the info in a database or anything....

1 thing to bear in mind is that more than we'd need to see all the responses on the "view messages" page - not just 1 at a time - hence the refreshing

It's a simple shoutscript i'm trying to do for an online radio station :)
 
You will need to store the messages somewhere otherwise you wont be able to view them like that.

When you send a forms variables to the server, they will only be alive for the time they are in use, as soon as the end of the code block is reached they will be discarded. If you want to view these messages in a list coming from all different places you will need to store them in a small database or file.
 
Back
Top Bottom