Jump to content

Search the Community

Showing results for tags 'Delay PHP'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • W3Schools
    • General
    • Suggestions
    • Critiques
  • HTML Forums
    • HTML/XHTML
    • CSS
  • Browser Scripting
    • JavaScript
    • VBScript
  • Server Scripting
    • Web Servers
    • Version Control
    • SQL
    • ASP
    • PHP
    • .NET
    • ColdFusion
    • Java/JSP/J2EE
    • CGI
  • XML Forums
    • XML
    • XSLT/XSL-FO
    • Schema
    • Web Services
  • Multimedia
    • Multimedia
    • FLASH

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Languages

Found 1 result

  1. HI all I hope someone can help me. I am using XAMPP and hosting an internal support website. With help from W3Schools and various other online pages, I have put together something quite simple. A user enters information on a page that is set out as follows: <?php session_start();$_SESSION["Valid"] = true;?><html><head> <script type="text/javascript"> function validateForm() { var sFName=document.forms["fQuery"]["sName"].value; var sEma=document.forms["fQuery"]["sEmail"].value; var sLoca=document.forms["fQuery"]["sLocation"].value; var sProb=document.forms["fQuery"]["sProblem"].value; var atpos=sEma.indexOf("@"); var dotpos=sEma.lastIndexOf("."); var blFormChk = true; if (sFName==null || sFName=="") { alert("Name must be filled in"); blFormChk = false; } if (sEma==null || sEma=="") { alert("A valid email address must be filled in"); blFormChk = false; } if (checkEmail(sEma) == false) { alert("Not a valid e-mail address"); blFormChk = false; } if (sLoca==null || sLoca=="") { alert("Please give the location"); blFormChk = false; } if (sProb.length < 30) { alert("Please submit a more detailed query"); blFormChk = false; } return blFormChk; } function checkEmail(checkStr) { var blValid = false; for (var i=0; i<checkStr.length; i++) { var chAtI = checkStr.charCodeAt(i); if ((chAtI<45) || (chAtI==47) || ((chAtI>57) && (chAtI<64)) || ((chAtI>90) && (chAtI<95)) || (chAtI==96) || (chAtI>122)) { blValid = false; } else { blValid = true; } if (blValid == false) { break; } } if (blValid == true) { sConv = checkStr.split("@"); if (sConv.length == 2) { blValid = true;} else { blValid = false; } if (blValid == true) { if ((sConv[0].length > 0) && (sConv[1].length > 0)) { blValid = true; } else { blValid = false; } } if (blValid == true) { sDom = sConv[1].split("."); if (sDom.length==1) { blValid = false; } else { for (var j=0; j<sDom.length; j++) { if (sDom[j].length > 0) { blValid = true; } else { blValid = false; break; } } } } } return blValid; } </script><title>Support Query</title><link rel="shortcut icon" href="/favicon.ico" /></head><body style="background-color:#000066;color:#FFFFFF"> <h1>Company</h1> <h2>Submit a Support Query</h2> <table border=0> <form name="fQuery" action="QueryList.php" onsubmit="return validateForm()" method="post"> <tr> <td> <p>* Required fields</p> <br /> * Name: <br /> <input type="text" name="sName" size="60" maxlength="120" value=""/> <br /> * E-mail address: <br /> <input type="text" name="sEmail" size="60" maxlength="120" value="" /> <br /> Where to find you or contact number: <br /> <input type="text" name="sContact" size="60" maxlength="120" value="" /> <br /> * Location related to query (eg. Room 23, Staffroom): <br /> <input type="text" name="sLocation" size="60" maxlength="180" value="" /> <br /> Type of device related to query (eg. Projector, Sound Box, Computer): <br /> <input type="text" name="sDevice" size="60" maxlength="180" value="" /><br /> <br /> * Query (Please give details): <br /> <textarea name="sProblem" cols='60' rows='6' onkeypress="nCount.innerHTML=250-sProblem.value.length" onkeyup="nCount.innerHTML=250-sProblem.value.length" onkeydown="nCount.innerHTML=250-sProblem.value.length"></textarea> <label for="sProblem" id="nCount">250</label> </tr> <tr> <td> <br /> Please only click submit ONCE and wait for your ticket number.<br /> It may take up to a minute for a confirmation page to be displayed. </td> </tr> <tr> <td> <br /> <input type="submit" value="Submit"/> </td> </tr> </form> </table></body></html> Then they click the submit button and the information goes to the next page: <?php session_start();?><html><head> <link rel="shortcut icon" href="/favicon.ico" /></head><body style="background-color:#000066;color:#FFFFFF"><?php $sFileDate = Date("Ym"); $fDataFile = "./Datafiles/".$sFileDate.".csv"; $fQueries = fopen($fDataFile,"a"); $nCounter = count(file($fDataFile)); if ($nCounter == 0) { fwrite($fQueries,("TicketNo,Name,Email,ContactNo,Location,Device,Query")); $nCounter = 1; } $sPost = vsprintf("%'04s",$nCounter); if ($_SESSION["Valid"] === true) { $_SESSION["Valid"] = false; $aData = array(Date("Ym"),$sPost,",",str_ireplace(",",";",$_POST["sName"]),",",str_ireplace(",",";",$_POST["sEmail"]),",",str_ireplace(",",";",$_POST["sContact"]),",",str_ireplace(",",";",$_POST["sLocation"]),",",str_ireplace(",",";",$_POST["sDevice"]),",","\"".(str_ireplace(array("\n","\r","\r\n")," ",str_ireplace(",",";",$_POST["sProblem"])))."\""); fwrite($fQueries,("\r\n".implode($aData))); fclose($fQueries); set_time_limit(60); mail("//data has been removed"); set_time_limit(60); mail("//data has been removed"); } else {$sPost = vsprintf("%'04s",$nCounter-1);}?><h1>Thank you</h1><p>Your support ticket number is <h2><b><?php print_r(Date("Ym").$sPost);?></b></h2>This ticket number has been emailed to: <?php print_r($_POST["sEmail"]);?></p><p>An email has been sent to support with your query. You should be contacted soon.</p></body></html> And it all works wonderfully... except that the two mail() entries take a while to send. This appears to be causing complications. Before I had the "set_time_limit(60);" lines in, 30seconds in and the script would terminate with an error that the users see. The time limits now stop the error but the user can wait up to 1:59s before it displays the page. Anything beyond that and it gives an error. Is there a way I can display the output page, giving them their reference number while running the mail sending in the background? And if they try close the page, it should give a message saying that it is still sending the mails? Your help would be greatly appreciated.
×
×
  • Create New...