Jump to content

Processing with php


timmah1

Recommended Posts

I have a form that processes information for health insurance.

It works great!

But this client wants, that after you click on 'submit', it shows like an animation or words 'Processing information', then show the results.

I'm not sure how to do this.

 

I tried

<?
if($_POST['submit']){
echo 'Processing information. Please wait';
sleep(5);

}
?>

and that works great, but the 'Processing information. Please wait stays after the 5 seconds.

Is there any way to make that disappear, or do you have a different solution, beside AJAX?

 

I'm not that familiar with AJAX, and I'm afraid I'd have to re-do the entire form.

 

Thanks in advance/

Link to comment
https://forums.phpfreaks.com/topic/127471-processing-with-php/
Share on other sites

It shouldn't honestly be too bad.  I'd use a JS framework to set up the Ajax functionality though, instead of hacking together some solution that probably isn't optimal.  I'd suggest Prototype if you just want Ajax, and script.aculo.us (an add-on to Prototype) if you want to use actual effects with the Ajax.  I happen to love script.aculo.us. =P  The form won't really need redesign, it's probably going to be the PHP page that needs reworking.

 

Also, don't use short tags.  =P

Link to comment
https://forums.phpfreaks.com/topic/127471-processing-with-php/#findComment-659494
Share on other sites

I use something that is much simpler (although less dynamic, too). On the submitting page, have an onunload event in the body that displays a "Please Wait" image and/or text. Then have the same thing on the post-to page, except it is displayed by default and is removed using the onload event, again in the body.

Link to comment
https://forums.phpfreaks.com/topic/127471-processing-with-php/#findComment-659505
Share on other sites

<html>
<head>
<script type="text/javascript">
function onlyHide(id) {
  document.getElementById(id).style.display = "none";
}
function onlyShow(id) {
  document.getElementById(id).style.display = "block";
}
</script>
</head>
<body onload="onlyHide('pleasewait');" onunload="onlyShow('pleasewait');">
<table width="100%" height="100%" cellpadding="5" id="pleasewait" style="display:block;z-index:1;position:absolute;left:0px;top:0px;">
   <tr height="225">
      <td width="100%" colspan="3">
          
      </td>
   </tr>
   <tr>
      <td width="49%">
          
      </td>
      <td align="center" valign="middle" width="2%" nowrap bgcolor="#FFFFFF" style="border: solid 1px black;">
         Please wait...<br>
         <image src="images/pleasewait.gif">
      </td>
      <td width="49%">
          
      </td>
   </tr>
</table>
<!-- Add the rest of your page here -->

 

Grab the image from this topic:

http://www.phpfreaks.com/forums/index.php/topic,219292.msg1005499.html#msg1005499

Link to comment
https://forums.phpfreaks.com/topic/127471-processing-with-php/#findComment-659509
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.