Forum Moderators: coopster

Message Too Old, No Replies

form should load first..

         

babloo

6:22 am on Sep 28, 2004 (gmt 0)

10+ Year Member



Hello,

I am running a script which sends an email first then shows an html form. But here what happens, it is taking so long to load the html form because of the mail function. Once mail function executes, the form loads.

I want to run the mail function behind the scene and show the form first. I have tried with the php flush() also. Can anyone please help me regarding this.
I want to show the form first instead of waiting for the mail function to finish execute.

Thanks

grandpa

6:40 am on Sep 28, 2004 (gmt 0)

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



Hi, I'd be curious to find out why the mail function takes more than about 1/2 second. It sounds to me as if your script may be doing more than sending mail, or its having some technical difficulty... a glitch. Would you care to share the relevant code?

Besides that I suppose the script might be modified to run the mail function after you process the form. Of course, I haven't seen the script so I can only speculate about how easy that may be.

babloo

6:55 am on Sep 28, 2004 (gmt 0)

10+ Year Member



Thank you for your comments.
Definetely, i don't mind in giving the sample of the code..

//My form comes here..
<form method=post action=''>
some hidden fields..
<input type=text name='name'>
<input type=age name='age'><br>
<input type=submit>
</form>

<?
$message = "Visitor has come to the form";

//My mail function comes here

mail( "", $subject, $message, "From: FrmName <FrmEmail>") ;

THis is a very simple mail function..What could be wrong in this? When I comment the mail function, the form loads faster..

Thanks

mincklerstraat

7:14 am on Sep 28, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The mail function has to tell the sendmail program (or other mail program your server uses in the background) to do its stuff, and then wait around while it does this stuff, making sure that everything's ok and there are no errors to report. And it's pretty standard for a php page just not to show until everything is done.

Yes, I'd use flush() - first show the output you want, flush(), then mail(), then give any extra output (success /failure).