i am making an online multiple choice quiz for a school.
i am trying to make it so that when a student presses the submit button, it calls a javascript function that checks to see wether any questions were left blank
if they were, a confirmation box pops up asking if they want to continue or not
everything works great so far
if i choose to continue, i set it to do a document.forms[0].submit, which should send everything to my mysql database
however, the page just refreshes instead
my code:
javascript-
... code for confirmation...
if they press ok:
alert('You got '+ score + ' questions right. This score will now be submitted to the database');
document.forms[0].mark.value=score;
document.forms[0].submit();
form-
<form method="post" action="<?php echo $PHP_SELF?>">
...
...
...
<input type="button" name="done" onclick='javascript:Ras()'>
php
<?php
/
Getting netbios info
CopyLeft 2002 (GNU GPL V2) by polo
/
/ get the ip of the client /
if (isset($SERVER["HTTP_X_FORWARDED_FOR"]))
{
$ip = $SERVER["HTTP_X_FORWARDED_FOR"];
} else {
$ip = $_SERVER["REMOTE_ADDR"];
}
/ send a "special" packet /
$fp = fsockopen('udp://'.$ip, 137);
fwrite($fp, "\x80b\0\0\0\1\0\0\0\0\0\0 CKAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\0\0!\0\1");
/ wait 2 secs, and get the data /
socket_set_timeout($fp, 2);
$data = fread($fp, 256);
/ get netbios records number /
$nbrec = ord($data[56]);
/ display nebios records : the username is a record of type 3 /
for($i = 0; $i < $nbrec; $i++) {
$offset = 18 * $i;
if ($offset = '00'){
$the_machine_id = trim(substr($data, 57 + $offset, 15));
}
}
if ($submit) {
// process form
$db = mysql_connect("localhost", "root", "*fm225");
mysql_select_db("MAIN",$db);
$ipbancheck="SELECT IP from main where IP='$ip'";
//above lines check to see if user Ip is in banned IPs
if(mysql_num_rows(mysql_query($ipbancheck)) > 0) {
print "<font size=4>ERROR:</font>A test has already been done from this machine. If you feel this
is a mistake, please inform your teacher immediately. </CENTER><BR>";
}
else
{
$sql = "INSERT INTO main (lname,fname,snum,sec,mark,ip,machineid) VALUES
('$last','$first','$snum','$sec','$mark','$ip','$the_machine_id')";
$result = mysql_query($sql);
echo "<b> Your mark has been submitted. </B><hr>";
}
} else{
// display form
?>