Forum Moderators: coopster

Message Too Old, No Replies

PHP form "Please Wait While Loading"

         

puckparches

12:05 am on Nov 18, 2006 (gmt 0)

10+ Year Member Top Contributors Of The Month



I have a huge database and I would like to show a message "please wait while searching our database" message just after the user presses submit. I did some research and I found a scrip that shows the message, but it shows the message too late. (I add the script in the results page)

Is any way I can make the page go blank (the page with the form) and show only the message while the page is loading?

dreamcatcher

7:59 am on Nov 18, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi puckparches,

I would use a meta refresh.


function refresh($search_data)
{
$html = '<html>';
$html .= '<head><title>Searching..</title></head>';
$html .= '<meta http-equiv=refresh content="3; url=search.php?keywords='.$search_data.'">';
$html .= '<body>';
$html .= 'Searching...please wait...';
$html .= '</body></html>';
exit;
}

Then on search submit you could use:

if (isset($_POST['keywords']))
{
echo refresh($_POST['keywords']);
}

Something like that might be ok. Or you can use javascript to pop up a message on submit.

dc

justageek

3:37 pm on Nov 18, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Or you might try to flush() the buffer right after the message. The script is probably trying to hold all the output until it is done which would explain why it shows to 'late'. Flushing the buffer will force the message to be displayed even though the script is still running.

JAG

pixeltierra

7:20 pm on Nov 19, 2006 (gmt 0)

10+ Year Member



Ajax can work here pretty well.

puckparches

9:39 pm on Nov 19, 2006 (gmt 0)

10+ Year Member Top Contributors Of The Month



Thanks for your response!

I try to uses flush(), but I'm not very familiar and I could make it work.

Then I tried the suggestion of dreamcatcher but I really didn't understand where to add the code. In the search page or in the result page.

I had:

search.php (with a template) --> results.php (with template)

I did some more research (I was hoping to find a example with AJAX, but I couldn't find it) and I found the following.

Make and extra page between the two that shows the message. with a meta redirection (like dreamcatcher suggested):

<META HTTP-EQUIV="refresh" content=1;URL="results.php?search_fields_">

Now I have:

search.php (with template) --> wait.php(with template) --> results.php (with template)

Is not working the way I really wanted to work but is better than nothing. The only downside is that is increasing the wait for the results to the already long wait.

Thanks again guys!