Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: [js][php] -odliczanie w teście online
Forum PHP.pl > Forum > Przedszkole
tomczas
Witam!!

Mam taki problem. Od razu mówię, że nie znam kompletnie js dlatego proszę o jasne tłumaczenia. W html napisałem formularz testowy (radio button, jedna możliwośc do wyboru). W php napisałem obsługe tego formularza. No i teraz przejdę do sedna sprawy. Potrzebny mi skrypt gdzie załóżmy po 10 minutach test wyłączy się i wyśle mi maila z wynikami, niezależnie od tego czy zdający skończył ten test czy nie.Poniżej dam dotychczasowe skrypty.

formularz.html:
CODE
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title></head>

<body>
<!--TEST ESK-->
<form action="obsluga.php" method="post">
<fieldset><legend> <center><b>SkyEurope VA Test. Remember that only one answer is correct!! Good Luck!!</b> </legend>
<p><strong>Name and surname:<br /><input type="text" name="name" size="20" maxlength="40" /> </strong></p>
<p><b>1:What does it mean STAR</b><br />
<input type="radio" name="1" value="a">Standard Terminal Approach Route<br />
<input type="radio" name="1" value="b">Standard Terminal Arrival Route<br />
<input type="radio" name="1" value="c">Super Transit Arrival Route <br />
<p><b>2:Wind is 150 degrees at 21kts. Which runway to land will you choose primary:</b><br />
<input type="radio" name="2" value="a">12<br />
<input type="radio" name="2" value="b">19<br />
<input type="radio" name="2" value="c">07 <br />
<p><b>3:Which of the following headings leads to the South most? (in degrees)</b><br />
<input type="radio" name="3" value="a">078<br />
<input type="radio" name="3" value="b">194<br />
<input type="radio" name="3" value="c">299<br />
<p><b>4:EPWA 301500Z 17004KT 140V210 7000 BKN023 00/M03 Q1022 NOSIG. <br />This is metar for Warsaw. What dose the 7000 and NOSIG refer to:</b><br />
<input type="radio" name="4" value="a">the visibility is limited to 7 kilometers and there are no significant changes expected<br />
<input type="radio" name="4" value="b">the visibility is less than 7 miles and the SIGMET is not up to date<br />
<input type="radio" name="4" value="c">the visibility is limited to 7000 feet and no significant changes are expected<br />
<p><b>5:You lost your radio. Which squawk will you choose:</b><br />
<input type="radio" name="5" value="a">
7000<br />
<input type="radio" name="5" value="b">
7600<br />
<input type="radio" name="5" value="c">
7500
<p><b>6:</b><strong>What is SVFR flight:</strong><br />
<input type="radio" name="6" value="a" />
search and rescue fligh<strong>t</strong>
<br />
<input type="radio" name="6" value="b" />
ifr flight with visibility less than 50m
<br />
<input type="radio" name="6" value="c" />
ifr flight with visibility less than 100m
<p><br />
<p><b>7:What does it CAVOK mean:</b><br />
<input type="radio" name="7" value="a">Clouds and Certical overcast<br />
<input type="radio" name="7" value="b">Cloud and Visibility OK<br />
<input type="radio" name="7" value="c">Clouds and V1 OK<br />
<p><b>8:What does it OM mean:</b><br />
<input type="radio" name="8" value="a">On board maps<br />
<input type="radio" name="8" value="b">outer marker<br />
<input type="radio" name="8" value="c">output marker<br />
<p><b>9:ZFW is:</b><br />
<input type="radio" name="9" value="a">Zero flight weight<br />
<input type="radio" name="9" value="b">Zero flight wind<br />
<input type="radio" name="9" value="c">Zero fuel weight<br />
<p><b>10:What is MZFW for Boeing 737-700?:</b><br />
<input type="radio" name="10" value="a">
121700lbs<br />
<input type="radio" name="10" value="b">140600lbs<br />
<input type="radio" name="10" value="c">
110500lbs<br />
</fieldset>
<div align="center">
<input type="submit" name="submit" value="Send test" /> </div>
</form>

</body>
</html>


obsluga.php:
CODE

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>
<?php
$name = $_POST['name'];
$odpowiedz[1] = 'b';
$odpowiedz[2] = 'a';
$odpowiedz[3] = 'b';
$odpowiedz[4] = 'a';
$odpowiedz[5] = 'b';
$odpowiedz[6] = 'a';
$odpowiedz[7] = 'b';
$odpowiedz[8] = 'b';
$odpowiedz[9] = 'c';
$odpowiedz[10] = 'a';

$pkt = 0;
$zle = 2;

$ile_pytan = count($odpowiedz);
for($x=1;$x<=$ile_pytan;++$x){
if($_POST["$x"] == $odpowiedz[$x]) { ++$pkt; }

}
$wynik = $name." you get " . $pkt . " points / " . $ile_pytan . " possible";
echo $wynik;

if($pkt < 8) {
echo "<br>Staff of SkyEurope VA are sorry to say that, but you don't pass your exam. Good luck next time!!";
}
else{
echo "<br>Staff of SkyEurope inform you that you pass your exam";
}

mail("tomczas91@gmail.com", "Wynik", $wynik, "From: SkyEurope Va test");
mail("ptychu45@wp.pl", "Wynik", $wynik, "From: SkyEurope Va test");

?>
</body>
</html>


Pozdrawiam i z góry dziękuję
tomczas
sticker
setTimeout i ktory wywołuje skrypt poprzez ajax na serverze przesyłający dane z forma Skorzystaj z biblioeki prototype na przykład
tomczas
eh a jaśniej?? Mówiłem, że kompletnie nie znam się na js, nie mówiąc już o ajaxie...
To jest wersja lo-fi głównej zawartości. Aby zobaczyć pełną wersję z większą zawartością, obrazkami i formatowaniem proszę kliknij tutaj.
Invision Power Board © 2001-2025 Invision Power Services, Inc.