The purpose of the form is to test student knowledge. As the student takes the test, each response is checked with Javascript for correctness yielding a cumulative score.
When the test is finished and the student clicks the 'Send Assignment' button, the answers and score along with name and email address are sent in an email back to me. PHP (LMLsubmit2.php) is doing the checks for a valid, student email address, gathering the form info, and sending the email. BUT what's happening is, it checks for a valid, student email address and as soon as it has one, it sends an email to me every time a question is answered without the 'Send Assignment' button being clicked. PHP is doing a beautiful job collecting and sending all the information, and the java checking is working too, but criminey, I don't need an email every time a student answers a question!
I'm a beginner in PHP or Java and don't know much - just enough to adapt and get by - and this one's got me stumped.
I've posted both the HTML page and PHP file being used below, but taken out my email address in LMLsubmit2.php where it should be: $emailmanager = 'someone@somewhere.com'. If you can help and need to see the form in action, please message me and I'll send you the link.
Thank you in advance.
Jeff
PHP:
<?php
$emailmanager = 'someone@somewhere.com';
error_reporting(0);
$msg = '';
foreach ($_POST as $k => $v) { $msg .= $k.': '.$v."\n"; }
$email = trim($_POST['email']);
$Ok = ereg("^([a-zA-Z0-9_\.-]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$", $email);
$headers = 'From: ' . $email . "\n";
$headers .= 'MIME-Version: 1.0' ."\n";
$headers .= 'Content-Type: text/plain; charset=iso-8859-1' ."\n";
$headers .= 'Content-Transfer-Encoding: 8bit'. "\n\n";
if ($Ok) {
mail($emailmanager,'Test Answers',$msg,$headers);
?>
<script language = 'javascript'>
alert('Thank you. Your work has been received.');
history.go(-1);
</script>
<?
} else {
?>
<script language = 'javascript'>
alert('Sorry, please provide a valid Email address.');
history.go(-1);
</script>
<?
}
?>
HTML:
<HTML>
<HEAD>
<TITLE>Art Terms Quiz</TITLE>
<SCRIPT LANGUAGE="JavaScript">
var score = 0;
var done = new Array;
ans=new Array();
ans[1]="10";
ans[2]="19";
ans[3]="9";
ans[4]="18";
ans[5]="8";
ans[6]="17";
ans[7]="7";
ans[8]="16";
ans[9]="6";
ans[10]="15";
ans[11]="5";
ans[12]="14";
ans[13]="4";
ans[14]="13";
ans[15]="3";
ans[16]="12";
ans[17]="2";
ans[18]="11";
ans[19]="1";
function checkit(question, answer, other) {
if (answer != ans[question]) {
if (!done[question]) {
done[question] = -1;
alert("Sorry! You missed that one.\n\nYour score is now: " + score);
}
else {
alert("You have already tried to answer that Question!");
}
}
else {
if (!done[question]) {
done[question] = -1;
score++;
alert("Correct!\n\nYour score is now: " + score);
document.forms[0].Score.value = score;
}
else {
alert("You have already tried to answer that Question!");
}
}
msg(other);
}
function bzzt() {
alert("Don't worry about changing the number!");
document.forms[0].Score.value = score;
}
</SCRIPT>
</HEAD>
<BODY bgcolor="white" text="black" vlink="FF0000" link="0000FF" >
<TABLE>
<TR><TD></TD>
<TD><H2>Art Terms Quiz</H2></TD></TR></TABLE>
<!-- Mailer -->
<FORM NAME="mailer" METHOD="post" ACTION="LMLsubmit2.php">
<TABLE BORDER=0>
<TR VALIGN="top">
<TD><B>Your Name:</B></TD>
<TD><INPUT TYPE="text" SIZE=32 NAME="name" onChange="msg(this.form)"></TD>
</TR>
<TR VALIGN="top">
<TD><B>Your Email:</B></TD>
<TD><INPUT TYPE="text" SIZE=32 NAME="email" onChange="msg(this.form)"></TD>
</TR>
<TR VALIGN="top">
<TD><B>Subject:</B></TD>
<TD><INPUT TYPE="text" SIZE=32 NAME="subject" VALUE="Art" onChange="msg(this.form)"></TD>
</TR>
<TR VALIGN="top">
<TD><B>Lesson:</B></TD>
<TD><INPUT TYPE="text" SIZE=32 NAME="lesson" VALUE="Art Terms Quiz" onChange="msg(this.form)"></TD>
</TR>
</TABLE>
<BR>
<B>Instructions: </B>Match the number with the definition. When you are finished with your assignment, press the "Send Assignment" button.
<BR>
<BR>
<TABLE>
<FONT SIZE = +1><B>Vocabulary Choices</B>
<BR><BR>
<TR>
<TD WIDTH=150>1. Color</TD>
<TD WIDTH=150>2. Line</TD>
<TD WIDTH=150>3. Value</TD>
</TR>
<TR>
<TD WIDTH=150>4. Shape</TD>
<TD WIDTH=150>5. Form</TD>
<TD WIDTH=150>6. Balance</TD>
</TR>
<TR>
<TD WIDTH=150>7. Texture</TD>
<TD WIDTH=150>8. Symmetry</TD>
<TD WIDTH=150>9. Asymmetry</TD>
</TR>
<TR>
<TD WIDTH=150>10. Contrast</TD>
<TD WIDTH=150>11. Dominance</TD>
<TD WIDTH=150>12. Repetition</TD>
</TR>
<TR>
<TD WIDTH=150>13. Rhythm</TD>
<TD WIDTH=150>14. Theme</TD>
<TD WIDTH=150>15. Unity</TD>
</TR>
<TR>
<TD WIDTH=150>16. Aesthetic</TD>
<TD WIDTH=150>17. Expression</TD>
<TD WIDTH=150>18. History</TD>
</TR>
<TR>
<TD WIDTH=150>19. Valuing</TD>
</TR>
</TABLE>
<BR>
<FONT SIZE = +1><B>Definitions</B></FONT>
<FONT COLOR="BLACK">
<BR><BR>
<B>1.</B> Use of opposites in close proximity (light and dark, rough and smooth).
<BR>
<INPUT TYPE="text" SIZE=3 NAME="Question#1" onChange="checkit(1, this.value, this.form)">
<BR>
<BR>
<B>2.</B> Use analysis, interpretation, and judgment about visual relationships based on learned aesthetic values to improve art production.
<BR>
<INPUT TYPE="text" SIZE=3 NAME="Question#2" onChange="checkit(2, this.value, this.form)">
<BR>
<BR>
<B>3.</B> A balance achieved through the use of unequal parts or elements.
<BR>
<INPUT TYPE="text" SIZE=3 NAME="Question#3" onChange="checkit(3, this.value, this.form)">
<BR>
<BR>
<B>4.</B> Study a variety of artworks and accomplishments of contemporary, historic, and prehistoric cultures.
<BR>
<INPUT TYPE="text" SIZE=3 NAME="Question#4" onChange="checkit(4, this.value, this.form)">
<BR>
<BR>
<B>5.</B> A balance in which elements are alike and will appear to demand one another as a line that falls in one direction demands a line that falls in another direction.
<BR>
<INPUT TYPE="text" SIZE=3 NAME="Question#5" onChange="checkit(5, this.value, this.form)">
<BR>
<BR>
<B>6.</B> Develop manipulative and organizational skills in using visual arts media effectively to translate ideas, feelings, and values.
<BR>
<INPUT TYPE="text" SIZE=3 NAME="Question#6" onChange="checkit(6, this.value, this.form)">
<BR>
<BR>
<B>7.</B> The surface quality of material, either actual (tactile) or visual.
<BR>
<INPUT TYPE="text" SIZE=3 NAME="Question#7" onChange="checkit(7, this.value, this.form)">
<BR>
<BR>
<B>8.</B> See the world directly and metaphorically by perceiving the physical world in terms of visual and tactile images and symbols which are unique to the visual arts.
<BR>
<INPUT TYPE="text" SIZE=3 NAME="Question#8" onChange="checkit(8, this.value, this.form)">
<BR>
<BR>
<B>9.</B> An equilibrium of similar, opposing, or contrasting elements that together create a unity.
<BR>
<INPUT TYPE="text" SIZE=3 NAME="Question#9" onChange="checkit(9, this.value, this.form)">
<BR>
<BR>
<B>10.</B> The distinguishable units or elements that seem to belong to each other so that each contributes something to the functioning of the whole.
<BR>
<INPUT TYPE="text" SIZE=3 NAME="Question#10" onChange="checkit(10, this.value, this.form)">
<BR>
<BR>
<B>11.</B> A three-dimensional volume with the same qualities as "Shape" (above), or the illusion of three dimensions.
<BR>
<INPUT TYPE="text" SIZE=3 NAME="Question#11" onChange="checkit(11, this.value, this.form)">
<BR>
<BR>
<B>12.</B> Some dominant feature repeated with variations to give the work its dominant character.
<BR>
<INPUT TYPE="text" SIZE=3 NAME="Question#12" onChange="checkit(12, this.value, this.form)">
<BR>
<BR>
<B>13.</B> A two-dimensional area or plane that may be organic or inorganic, free-form or geocentric, open or closed, natural or of human origin.
<BR>
<INPUT TYPE="text" SIZE=3 NAME="Question#13" onChange="checkit(13, this.value, this.form)">
<BR>
<BR>
<B>14.</B> The regular repetition of particular forms or stresses; also, the suggestion of motion.
<BR>
<INPUT TYPE="text" SIZE=3 NAME="Question#14" onChange="checkit(14, this.value, this.form)">
<BR>
<BR>
<B>15.</B> Light and dark; the gradations of light and dark on the surface of objects.
<BR>
<INPUT TYPE="text" SIZE=3 NAME="Question#15" onChange="checkit(15, this.value, this.form)">
<BR>
<BR>
<B>16.</B> The recurrence of elements at regular intervals.
<BR>
<INPUT TYPE="text" SIZE=3 NAME="Question#16" onChange="checkit(16, this.value, this.form)">
<BR>
<BR>
<B>17.</B> An identifiable path of a point moving in space. It can vary in width, direction, and length.
<BR>
<INPUT TYPE="text" SIZE=3 NAME="Question#17" onChange="checkit(17, this.value, this.form)">
<BR>
<BR>
<B>18.</B> The difference in importance or emphasis of one aspect in relation to all other aspects of a design.
<BR>
<INPUT TYPE="text" SIZE=3 NAME="Question#18" onChange="checkit(18, this.value, this.form)">
<BR>
<BR>
<B>19.</B> Visual sensation dependent on the reflection or absorption of light from a given surface ("hue," "value," and "intensity" being the primary characteristics).
<BR>
<INPUT TYPE="text" SIZE=3 NAME="Question#19" onChange="checkit(19, this.value, this.form)">
<BR>
<BR>
Your score is <INPUT TYPE="Text" NAME="Score" SIZE="2" MAXLENGTH="2" VALUE="0" onChange="bzzt
(this.form)"> out of 19.
<INPUT TYPE="submit" VALUE="Send Assignment">
<!--<INPUT TYPE="reset" VALUE="Erase Everything">-->
</FORM>
</BODY>
</HTML>