0

结构是这样的。

用户使用凭据登录。(userdetails.php)

如果成功输入 email_id (有助于创建特定用户的表)

问题1:显示

如果用户点击下一步

问题2:显示器

很快

问题是它应该在 90 秒后自动提交(每个问题)或者所有计时器也很好。

用户详情.php

<html>
<head>
</head>
<body>

<form action="" method="POST">



<b>Enter Username:</b><input type="text" name="username" value=""/><br>

<b>Enter Password: </b><input type="password" name="password" value=""/><br>

<input type="submit" value="submit" name="submit"/>
<input type="reset" value="reset" name="reset"/>

</form>

<?php


if (isset($_POST['submit'])) 
{

$username=$_POST['username'];
$password=$_POST['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 "<br/>";
print "<b>Incorrect Username/Password!!!</b>";
}
else
{
//mysql_query("Create table $username(Question_No varchar(10),Selected_Answer varchar(10))") 
 //or die("error in creating table");  
print "<br/>";
print "<b>Login successful!!!</b><br/><br/>";
//print "<script>window.open('best.php')</script>";
print "<script>window.open('best.php?username=$username')</script>";
print "<script>window.close()</script>";
}

}
?>

</body>
</html>

最好的.php

<!DOCTYPE html>

<html><head><title>Bestnetcraft - Online Test Engine </title>
<style type="text/css">
b {font-family: arial; color:#0000FF;}
body {font-family: arial; color:#000000;}
</style>

<script language="javascript">
var started=90;
function run() 
{
setTimeout("showtime()",1000);
}
function showtime() 
{
started=started-1;
if (started <=0) 
{
//window.close();
autoin();
}
window.status="You have " + started + " seconds left";
run();
}

</script>


</head>
<body bgcolor="#FFFFFF" text="#000000" onload="run()">

<br><br>
<form name="quest" method="POST" action="">
<p align='left'>Enter Your Mail_id:<input type="text" id="username" name="username"/></p>

<p><b>Question 1 : </b> Vanessa and Brett had been arguing about their perceived 
proclivity to spend for hours together. What word describes the couple's predicament? <br></p>

  <p><input type="radio" value="Wrong" name="ans">Demarche </p>
  <p><input type="radio" value="Correct" name="ans">Impasse </p>

  <p><input type="radio" value="Wrong" name="ans">Mélange </p>
  <p><input type="radio" value="Wrong" name="ans">tête-à-tête </p>

<input type="submit" name="NEXT" value="Next">
</form>

<input type="hidden" name="what" value="english">
<input type="hidden" name="action" value="indi">
<input type="hidden" name="number" value="1">
<input type="hidden" name="total" value="0">
<input type="hidden" name="user" value="arun-english">

<hr>
<script language="JavaScript">

//autoincrement function

function autoin() 
{
document.write("<form name='auto' method='post' action=best1.php>");
document.write("<input type='hidden' name='number' value=2>");
document.write("<input type='hidden' name='user' value=arun-english>");
document.write("<input type='submit' value='Next'></form>");
document.auto.submit();
}
</script>

<?php

if (isset($_POST['NEXT'])) 
{

//echo '<script>alert("connected")</script>';
$op=$_POST["ans"];
$username=$_POST["username"];

mysql_connect("localhost", "root", "") or die(mysql_error()); 
mysql_select_db("demo") or die(mysql_error()); 

mysql_query("Create table $username(Question_No varchar(10),Selected_Answer varchar(10))") 
 or die("error in creating table"); 
//$DBName = "demo"; 
//$username=$_GET['username'];
//$dbTable = $DBName.".".$username; 

mysql_query("insert into $username values('Q1','$op')")
or die(mysql_error());

//print "<script>window.open('best1.php')</script>";
print "<script>window.open('best1.php?username=$username')</script>";
print "<a href=hello.php><script>window.close('best.php')</script></a>";
}
?>



</body>
</html>

best1.php

<!DOCTYPE html>
<html><head><title>Bestnetcraft - Online Test Engine </title>
<style type="text/css">
b {font-family: arial; color:#0000FF;}
body {font-family: arial; color:#000000;}
</style>

<!--<script language="javascript">
var started=90;
function run() {
setTimeout("showtime()",1000);
}
function showtime() {
started=started-1;
if (started <=0) {
//window.close();
autoin();
}
window.status="You have " + started + " seconds left";
run();
}

</script>-->


</head>
<body bgcolor="#FFFFFF" text="#000000" onload="run()">


<form name="quest" method="POST" action="">
<br><br>

<p><b>Question 2 : </b> Vanessa and Brett had been arguing about their perceived 
proclivity to spend for hours together. What word describes the couple's predicament? <br></p>

  <p><input type="radio" value="Wrong" name="ans">Demarche </p>
  <p><input type="radio" value="Correct" name="ans">Impasse </p>

  <p><input type="radio" value="Wrong" name="ans">Mélange </p>
  <p><input type="radio" value="Wrong" name="ans">tête-à-tête </p>

<input type="submit" name="NEXT" value="Next">
</form>

<!--<input type="hidden" name="what" value="english">
<input type="hidden" name="action" value="indi">
<input type="hidden" name="number" value="1">
<input type="hidden" name="total" value="0">
<input type="hidden" name="user" value="arun-english">


<hr>
<script language="JavaScript">
//autoincrement function
//function autoin() {
//document.write("<form name='auto' method='post' action=best1.php>");
//document.write("<input type='hidden' name='what' value=english>");
//document.write("<input type='hidden' name='action' value='indi'>");
//document.write("<input type='hidden' name='number' value=2>");
//document.write("<input type='hidden' name='total' value=0>");
//document.write("<input type='hidden' name='user' value=arun-english>");
//document.write("<input type='submit' value='Next'></form>");
//document.auto.submit();
//}
</script>-->

<?php

if (isset($_POST['NEXT'])) 
{


$op=$_POST["ans"];
$username=$_GET["username"];

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("insert into $username values('Q2','$op')")
or die(mysql_error());


//print "<script>window.open('best2.php')</script>";
print "<script>window.open('best2.php?username=$username')</script>";
print "<a href=hello.php><script>window.close('best1.php')</script></a>";
//print "<a href=hello.php><script>window.open('final.html')</script></a>";
}
?>
</body></html>

best2.php

<!DOCTYPE html>
<html><head><title>Bestnetcraft - Online Test Engine </title>
<style type="text/css">
b {font-family: arial; color:#0000FF;}
body {font-family: arial; color:#000000;}
</style>

<!--<script language="javascript">
var started=90;
function run() {
setTimeout("showtime()",1000);
}
function showtime() {
started=started-1;
if (started <=0) {
//window.close();
autoin();
}
window.status="You have " + started + " seconds left";
run();
}

</script>-->


</head>
<body bgcolor="#FFFFFF" text="#000000" onload="run()">


<form name="quest" method="POST" action="">
<p><b>Question 3 : </b> Vanessa and Brett had been arguing about their perceived 
proclivity to spend for hours together. What word describes the couple's predicament? <br></p>

  <p><input type="radio" value="Wrong" name="ans">Demarche </p>
  <p><input type="radio" value="Correct" name="ans">Impasse </p>

  <p><input type="radio" value="Wrong" name="ans">Mélange </p>
  <p><input type="radio" value="Wrong" name="ans">tête-à-tête </p>

<input type="submit" name="NEXT" value="Next">
</form>

<!--<input type="hidden" name="what" value="english">
<input type="hidden" name="action" value="indi">
<input type="hidden" name="number" value="1">
<input type="hidden" name="total" value="0">
<input type="hidden" name="user" value="arun-english">


<hr>
<script language="JavaScript">
//autoincrement function
//function autoin() {
//document.write("<form name='auto' method='post' action=best1.php>");
//document.write("<input type='hidden' name='what' value=english>");
//document.write("<input type='hidden' name='action' value='indi'>");
//document.write("<input type='hidden' name='number' value=2>");
//document.write("<input type='hidden' name='total' value=0>");
//document.write("<input type='hidden' name='user' value=arun-english>");
//document.write("<input type='submit' value='Next'></form>");
//document.auto.submit();
//}
</script>-->

<?php

if (isset($_POST['NEXT'])) 
{

$op=$_POST["ans"];
$username=$_GET["username"];

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("insert into $username values('Q3','$op')")
or die(mysql_error());
print "<a href=hello.php><script>window.open('final.html')</script></a>";
print "<a href=hello.php><script>window.close('best2.php')</script></a>";

}
?>
</body>
</html>

等等,.....

4

1 回答 1

0

因为setTimeout只运行一次。

setInterval是你所追求的。

于 2013-09-26T12:23:59.927 回答