Forum Moderators: coopster

Message Too Old, No Replies

How is this done? PHP, Javascript or both?

         

ktsirig

11:03 pm on Apr 28, 2006 (gmt 0)

10+ Year Member



Hi all!
I have a php page which contains a form. The user enters data and then the data is processed to give some results. What I would like to have is a page inbetween, that says, for instance, "Your job is being processed" or something similar, and then, when the job is done, refresh itself to show the results. I have seen it in many websites, but I don't know what I need to get me started...

patriko

2:49 am on Apr 29, 2006 (gmt 0)

10+ Year Member



That's completely PHP.

Let's say you have three pages: form.php, process.php, and results.php. On form.php, you would just have your simple HTML form, but make sure the form begins like this:

<form method="post" action="process.php">

That method="post" part is important. Remember to give all of the elements of your form valid names as well.

Now, in process.php, you will grab all of the form data from form.php. This is through the use of the $_POST array. $_POST has every element from the form on form.php in it for you to access/process as you please. (For example ... if you have an input box in form.php named "email_address", then to access the value of the element in process.php, simply use the variable $_POST["email_address"]. With that knowledge, you can process any of the variables as you see fit.

Now, if you want to print the results on results.php, there are many methods to approach. The easiest, I'd say, would be through the $_GET variable. It works exactly the same as $_POST, but only in that it's an array :-). In process.php, you'll want to redirect to results.php, but you'll want to pass a query string along with it. I can explain this best by example:

Let's say you want the result to read, simply, "Success". You would redirect from process.php to results.php by using the following at the end of your PHP code:

header("Location: results.php?theresult=Success");

This is assuming that headers have yet to be sent; that is, the only code on process.php is PHP code (as it should be anyway). Then, on results.php, simply print out the variable you passed: $_GET['theresult'] (theresult is the variable in the url above).

dreamcatcher

5:41 pm on Apr 29, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Its probably just a meta refresh that directs after x amount of seconds.

dc

ktsirig

8:44 pm on Apr 30, 2006 (gmt 0)

10+ Year Member



Hi, thank you all for your time!
Actually, what I do is not just take user's input and print it, but i use the data which the user sends as input to an external program that I call through PHP. This program is a bit slow, so I thought of using such a page (not a very complicated one) so that the user will see a message like "Jour job is being processed", and then, when the job is done, the page will refresh and show the results or will redirect to the results page.

eeek

8:49 pm on Apr 30, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



What I would like to have is a page inbetween, that says, for instance, "Your job is being processed" or something similar

Does it really take all that long to process the request? As a user I just plain hate those "Your job is being processed" pages--they slow things down.