Note that there are some explanatory texts on larger screens.

plurals
  1. POi am writing code to conduct online test , got trouble in auto submit
    text
    copied!<p>I have used PHP, JS , Mysql and Html Every thing is working except auto submit and timer.</p> <p>After 20 min it should auto submit with user selected option and stores in mysql. popups "timesup and tell your answer as been submitted".</p> <p>but its popping timesup msg and not auto submitting and executing php code to store values in mysql .</p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;/head&gt; &lt;body&gt; &lt;form action="" method="REQUEST"&gt; &lt;b&gt;Enter Username:&lt;/b&gt;&lt;input type="text" name="username" value=""/&gt;&lt;br&gt; &lt;b&gt;Enter Password: &lt;/b&gt;&lt;input type="password" name="password" value=""/&gt;&lt;br&gt; &lt;input type="submit" value="submit" name="submit"/&gt; &lt;input type="reset" value="reset" name="reset"/&gt; &lt;/form&gt; &lt;?php if (isset($_REQUEST['submit'])) { $username=$_REQUEST['username']; $password=$_REQUEST['password']; mysql_connect("localhost", "root", "") or die(mysql_error()); mysql_select_db("demo") or die(mysql_error()); $result=mysql_query("select * from employees where name='$username' and pass='$password'") or die(mysql_error()); if(mysql_num_rows($result)==0) { print "&lt;br/&gt;"; print "&lt;b&gt;Incorrect Username/Password!!!&lt;/b&gt;"; } else { print "&lt;br/&gt;"; print "&lt;b&gt;Login successful!!!&lt;/b&gt;&lt;br/&gt;&lt;br/&gt;"; print "&lt;script&gt;window.close()&lt;/script&gt;"; print "&lt;a href=hello.php&gt;&lt;script&gt;window.open('hello.php')&lt;/script&gt;&lt;/a&gt;"; } } ?&gt; &lt;/body&gt; &lt;/html&gt; code for hello.php &lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;script type="text/javascript"&gt; document.onmousedown=disableclick; status="Right Click Disabled"; function disableclick(event) { if(event.button==2) { alert(status); return false; } } function timedText() { var x=document.getElementById('txt'); var t1=setTimeout(function(){x.value="20 min "},9000); var t20m=setTimeout(function(){x.value="20 min"},60000); var t19m=setTimeout(function(){x.value="19 min"},120000); var t18m=setTimeout(function(){x.value="18 min"},180000); var t17m=setTimeout(function(){x.value="17 min"},240000); var t16m=setTimeout(function(){x.value="16 min"},300000); var t15m=setTimeout(function(){x.value="15 min"},360000); var t14m=setTimeout(function(){x.value="14 min"},420000); var t13m=setTimeout(function(){x.value="13 min"},480000); var t12m=setTimeout(function(){x.value="12 min"},540000); var t11m=setTimeout(function(){x.value="11 min"},600000); var t10m=setTimeout(function(){x.value="10 min"},660000); var t9m=setTimeout(function(){x.value="9 min"},720000); var t8m=setTimeout(function(){x.value="8 min"},780000); var t7m=setTimeout(function(){x.value="7 min"},840000); var t6m=setTimeout(function(){x.value="6 min"},900000); var t5m=setTimeout(function(){x.value="5 min"},960000); var t4m=setTimeout(function(){x.value="4 min"},1020000); var t3m=setTimeout(function(){x.value="3 min"},1080000); var t2m=setTimeout(function(){x.value="2 min"},1140000); var t1m=setTimeout(function(){x.value="1 min"},1200000); var t59=setTimeout(function(){x.value="59 sec "},1201000); var t58=setTimeout(function(){x.value="58 sec "},1202000); var t57=setTimeout(function(){x.value="57 sec "},1203000); var t56=setTimeout(function(){x.value="56 sec "},1204000); var t55=setTimeout(function(){x.value="55 sec "},1205000); var t54=setTimeout(function(){x.value="54 sec "},1206000); var t53=setTimeout(function(){x.value="53 sec "},1207000); var t52=setTimeout(function(){x.value="52 sec "},1208000); var t51=setTimeout(function(){x.value="51 sec "},1209000); var t50=setTimeout(function(){x.value="50 sec "},1210000); var t49=setTimeout(function(){x.value="49 sec "},1211000); var t48=setTimeout(function(){x.value="48 sec "},1212000); var t47=setTimeout(function(){x.value="47 sec "},1213000); var t46=setTimeout(function(){x.value="46 sec "},1214000); var t45=setTimeout(function(){x.value="45 sec "},1215000); var t44=setTimeout(function(){x.value="44 sec "},1216000); var t43=setTimeout(function(){x.value="43 sec "},1217000); var t42=setTimeout(function(){x.value="42 sec "},1218000); var t41=setTimeout(function(){x.value="41 sec "},1219000); var t40=setTimeout(function(){x.value="40 sec "},1220000); var t39=setTimeout(function(){x.value="39 sec "},1221000); var t38=setTimeout(function(){x.value="38 sec "},1222000); var t37=setTimeout(function(){x.value="37 sec "},1223000); var t36=setTimeout(function(){x.value="36 sec "},1224000); var t35=setTimeout(function(){x.value="35 sec "},1225000); var t34=setTimeout(function(){x.value="34 sec "},1226000); var t33=setTimeout(function(){x.value="33 sec "},1227000); var t32=setTimeout(function(){x.value="32 sec "},1228000); var t31=setTimeout(function(){x.value="31 sec "},1229000); var t30=setTimeout(function(){x.value="30 sec "},1230000); var t29=setTimeout(function(){x.value="29 sec "},1231000); var t28=setTimeout(function(){x.value="28 sec "},1232000); var t27=setTimeout(function(){x.value="27 sec "},1233000); var t26=setTimeout(function(){x.value="26 sec "},1234000); var t25=setTimeout(function(){x.value="25 sec "},1235000); var t24=setTimeout(function(){x.value="24 sec "},1236000); var t23=setTimeout(function(){x.value="23 sec "},1237000); var t22=setTimeout(function(){x.value="22 sec "},1238000); var t21=setTimeout(function(){x.value="21 sec "},1239000); var t20=setTimeout(function(){x.value="20 sec "},1240000); var t19=setTimeout(function(){x.value="19 sec "},1241000); var t18=setTimeout(function(){x.value="18 sec "},1242000); var t17=setTimeout(function(){x.value="17 sec "},1243000); var t16=setTimeout(function(){x.value="16 sec "},1244000); var t15=setTimeout(function(){x.value="15 sec "},1245000); var t14=setTimeout(function(){x.value="14 sec "},1246000); var t13=setTimeout(function(){x.value="13 sec "},1247000); var t12=setTimeout(function(){x.value="12 sec "},1248000); var t11=setTimeout(function(){x.value="11 sec "},1249000); var t10=setTimeout(function(){x.value="10 sec "},1250000); var t9=setTimeout(function(){x.value="9 sec "},1251000); var t8=setTimeout(function(){x.value="8 sec "},1252000); var t7=setTimeout(function(){x.value="7 sec "},1253000); var t6=setTimeout(function(){x.value="6 sec "},1254000); var t5=setTimeout(function(){x.value="5 sec "},1255000); var t4=setTimeout(function(){x.value="4 sec "},1256000); var t3=setTimeout(function(){x.value="3 sec "},1257000); var t2=setTimeout(function(){x.value="2 sec "},1258000); var t01=setTimeout(function(){x.value="1 sec "},1259000); var t0=setTimeout(function(){x.value="0 sec "},1260000);*/ var wc=setTimeout(function(){ document.getElementById("test").submit(); window.close(); window.open('timesup.html'); },9000); } &lt;/script&gt; &lt;/head&gt; &lt;body onload="timedText()" oncontextmenu="return false"&gt; &lt;h4 align="Center"&gt;All the Best &lt;br/&gt;&lt;/h4&gt; &lt;form id = "test" name="test" method="REQUEST"&gt; &lt;p align='right'&gt;&lt;b&gt;Time left : &lt;/b&gt;&lt;input type="text" id="txt" /&gt;&lt;/p&gt; &lt;p align='left'&gt;Enter Your Mail_id:&lt;input type="text" id="username" name="username"/&gt;&lt;/p&gt; &lt;pre&gt;&lt;p&gt;&lt;b&gt;Note:&lt;/b&gt; 1. &lt;strong&gt;&lt;i&gt;&lt;u&gt;Please Enter your Email id in the above text box&lt;/u&gt;&lt;/i&gt;&lt;/strong&gt; otherwise your answers will not be corrected. 2. Answer all the question, there is no negative markings. 3. Time given to answer all 30 questions is 20 min.&lt;/p&gt;&lt;/pre&gt; &lt;br&gt; &lt;p align="left"&gt;&lt;b&gt;Question 1 : &lt;/b&gt;A wheel that has 6 cogs is meshed with a larger wheel of 14 cogs. When the smaller &lt;br/&gt; wheel has made 21 revolutions, then the number of revolutions mad by the larger wheel is:&lt;br/&gt;&lt;/p&gt; &lt;input type="radio" name="q1" value="no" /&gt;&lt;label&gt;4&lt;/label&gt;&lt;br&gt; &lt;input type="radio" name="q1" value="no" /&gt;&lt;label&gt;9&lt;/label&gt;&lt;br&gt; &lt;input type="radio" name="q1" value="yes" /&gt;&lt;label&gt;12&lt;/label&gt;&lt;br&gt; &lt;input type="radio" name="q1" value="no" /&gt;&lt;label&gt;49&lt;/label&gt;&lt;br&gt; &lt;br /&gt; &lt;input type="submit" name="Submit" /&gt; &lt;p align="left"&gt;&lt;b&gt;Question 2 : &lt;/b&gt;A wheel that has 6 cogs is meshed with a larger wheel of 14 cogs. When the smaller &lt;br/&gt; wheel has made 21 revolutions, then the number of revolutions mad by the larger wheel is:&lt;br/&gt;&lt;/p&gt; &lt;input type="radio" name="q2" value="yes" /&gt;&lt;label&gt;4&lt;/label&gt;&lt;br&gt; &lt;input type="radio" name="q2" value="no" /&gt;&lt;label&gt;9&lt;/label&gt;&lt;br&gt; &lt;input type="radio" name="q2" value="no" /&gt;&lt;label&gt;12&lt;/label&gt;&lt;br&gt; &lt;input type="radio" name="q2" value="no" /&gt;&lt;label&gt;49&lt;/label&gt;&lt;br&gt; &lt;br /&gt; &lt;p align="left"&gt;&lt;b&gt;Question 3 : &lt;/b&gt;A wheel that has 6 cogs is meshed with a larger wheel of 14 cogs. When the smaller &lt;br/&gt; wheel has made 21 revolutions, then the number of revolutions mad by the larger wheel is:&lt;br/&gt;&lt;/p&gt; &lt;input type="radio" name="q3" value="no" /&gt;&lt;label&gt;4&lt;/label&gt;&lt;br&gt; &lt;input type="radio" name="q3" value="no" /&gt;&lt;label&gt;9&lt;/label&gt;&lt;br&gt; &lt;input type="radio" name="q3" value="no" /&gt;&lt;label&gt;12&lt;/label&gt;&lt;br&gt; &lt;input type="radio" name="q3" value="yes" /&gt;&lt;label&gt;49&lt;/label&gt;&lt;br&gt; &lt;br /&gt; &lt;p align="left"&gt;&lt;b&gt;Question 1 : &lt;/b&gt;A wheel that has 6 cogs is meshed with a larger wheel of 14 cogs. When the smaller &lt;br/&gt; wheel has made 21 revolutions, then the number of revolutions mad by the larger wheel is:&lt;br/&gt;&lt;/p&gt; &lt;input type="radio" name="q4" value="no" /&gt;&lt;label&gt;4&lt;/label&gt;&lt;br&gt; &lt;input type="radio" name="q4" value="no" /&gt;&lt;label&gt;9&lt;/label&gt;&lt;br&gt; &lt;input type="radio" name="q4" value="yes" /&gt;&lt;label&gt;12&lt;/label&gt;&lt;br&gt; &lt;input type="radio" name="q4" value="no" /&gt;&lt;label&gt;49&lt;/label&gt;&lt;br&gt; &lt;br /&gt; &lt;p align="left"&gt;&lt;b&gt;Question 2 : &lt;/b&gt;A wheel that has 6 cogs is meshed with a larger wheel of 14 cogs. When the smaller &lt;br/&gt; wheel has made 21 revolutions, then the number of revolutions mad by the larger wheel is:&lt;br/&gt;&lt;/p&gt; &lt;input type="radio" name="q5" value="yes" /&gt;&lt;label&gt;4&lt;/label&gt;&lt;br&gt; &lt;input type="radio" name="q5" value="no" /&gt;&lt;label&gt;9&lt;/label&gt;&lt;br&gt; &lt;input type="radio" name="q5" value="no" /&gt;&lt;label&gt;12&lt;/label&gt;&lt;br&gt; &lt;input type="radio" name="q5" value="no" /&gt;&lt;label&gt;49&lt;/label&gt;&lt;br&gt; &lt;br /&gt; &lt;p align="left"&gt;&lt;b&gt;Question 3 : &lt;/b&gt;A wheel that has 6 cogs is meshed with a larger wheel of 14 cogs. When the smaller &lt;br/&gt; wheel has made 21 revolutions, then the number of revolutions mad by the larger wheel is:&lt;br/&gt;&lt;/p&gt; &lt;input type="radio" name="q6" value="no" /&gt;&lt;label&gt;4&lt;/label&gt;&lt;br&gt; &lt;input type="radio" name="q6" value="no" /&gt;&lt;label&gt;9&lt;/label&gt;&lt;br&gt; &lt;input type="radio" name="q6" value="no" /&gt;&lt;label&gt;12&lt;/label&gt;&lt;br&gt; &lt;input type="radio" name="q6" value="yes" /&gt;&lt;label&gt;49&lt;/label&gt;&lt;br&gt; &lt;br /&gt; &lt;input type="submit" name="Submit" /&gt; &lt;/form&gt; &lt;?php echo '&lt;p id="inphp"&gt;&lt;script&gt;alert("hoooo");&lt;/script&gt;&lt;/p&gt;'; if (isset($_REQUEST['Submit'])) { echo '&lt;script&gt;alert("voila");&lt;/script&gt;'; $op1=$_REQUEST["q1"]; $op2=$_REQUEST["q2"]; $op3=$_REQUEST["q3"]; $op4=$_REQUEST["q4"]; $op5=$_REQUEST["q5"]; $op6=$_REQUEST["q6"]; mysql_connect("localhost", "root", "") or die(mysql_error()); mysql_select_db("demo") or die(mysql_error()); //$DBName = "demo"; $username=$_GET['username']; //$dbTable = $DBName.".".$username; mysql_query("Create TABLE $username(Question_No varchar(10),Selected_Answer varchar(10))") or die("Enter your mail id / Enter Valid mail id "); mysql_query("insert into $username values('Q1','$op1')") or die(mysql_error()); mysql_query("insert into $username values('Q2','$op2')") or die(mysql_error()); mysql_query("insert into $username values('Q3','$op3')") or die(mysql_error()); mysql_query("insert into $username values('Q4','$op4')") or die(mysql_error()); mysql_query("insert into $username values('Q5','$op5')") or die(mysql_error()); mysql_query("insert into $username values('Q6','$op6')") or die(mysql_error()); print "&lt;br/&gt;Thank you $username&lt;br/&gt;&lt;br/&gt;"; print "Your Answers as been submitted"; print "&lt;a href=hello.php&gt;&lt;script&gt;window.open('final.html')&lt;/script&gt;&lt;/a&gt;"; print "&lt;a href=hello.php&gt;&lt;script&gt;window.close('hello.php')&lt;/script&gt;&lt;/a&gt;"; } ?&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload