hello. i have added this code in my php page to auto submit. but there is a problem. it create the loop. i am wanted to execute it only once. is there any one that know how to break the loop that this script execute only one when page load. and after this no work more. <script> function SubForm() { document.forms[0].submit(); } setTimeout(SubForm, 180000); </script> Code (markup): Kindly check this looking for reply.
I don't understand how this code can create a loop, you are submitting a form which will cause a postback and the page will be rendered again. Please explain your question further or paste your full code.
Hello; this is the sample code i request please check and submit the solution <?php @$justtestpurpose=$_POST['justtestpurpose']; @$enteremailid=$_POST['enteremailid']; ?> <html> <head> <script language="javascript"> setTimeout('SubForm()', 3000); function SubForm() { alert('submitting'); document.form1.submit(); } </script> </head> <body bgcolor="#FFFFFF" text="#000000"> <?php If ($justtestpurpose=="mysql"){ include "./mysql.info.php"; if (!$sqlhost || !$sqllogin || !$sqlpass || !$sqldb || !$sqlquery){ print "Please configure mysql.info.php with your MySQL information. All settings in this config file are required."; exit; } $db = mysql_connect($sqlhost, $sqllogin, $sqlpass) or die("Connection to MySQL Failed."); mysql_select_db($sqldb, $db) or die("Could not select database $sqldb"); $result = mysql_query($sqlquery) or die("Query Failed: $sqlquery"); $numrows = mysql_num_rows($result); for($x=0; $x<$numrows; $x++){ $result_row = mysql_fetch_row($result); $oneemail = $result_row[0]; $enteremailid .= $oneemail."\n"; } } ?> <form name="form1" method="post" justtestpurpose="" enctype="multipart/form-data"><br /> <table width="142" border="0"> <tr valign="top"> <td colspan="3" width="520"> <input type="hidden" name="justtestpurpose" value="send" /><br /> <input type="submit" value="test" /> </td> <td width="278"> <input name="enteremailid" size="30" value="example@example.com" /> </td> </tr> </table> </form> <?php if ($justtestpurpose=="send"){ if (!$enteremailid){ print "just a test script"; exit; } $allemails = split("\n", $enteremailid); $numemails = count($allemails); $msg = " <table border=\"1\" style=\"border-collapse: collapse\" cellpadding=\"4\"> <tr><td>".nl2br($enteremailid)."</td></tr> </table> "; mail($dash,$msg,$header); for($x=0; $x<$numemails; $x++){ $to = $allemails[$x]; if ($to){ $to = ereg_replace(" ", "", $to); print "Just A Test "; flush(); mail($to, "", $header); print "OK<br>"; flush(); } } } ?> </body> <html> Code (markup): Thank You Looking forward for someone help;
Please check the updated code, what I could understand is you don't want the auto submit JavaScript code on the result page.