I'm having a very troubling issue. Maybe I'm just looking over something but I have looked at the code for several hours now, making small adjustments here and there to try to fix this problem. Basically what I am doing is trying to POST the values of this form into my next php file which then records it to a database and mails it to me. I am validating the information submitted on the form in my php executing file. The problem occurs whenever a person does not completely fill out the form and causes it to send back the error messages. My code refills the textboxes and dropdown boxes with the previously information but when it comes to checkboxes it does not at the moment. I took this functionality out for the time being because I found out that when the form is resubmitted the checkboxes are no longer even POSTing the correct values anymore when checked. I have a little test at the bottom of my form to show me the values that my php exec file is sending back (located in the echo $c $obj part) All future submissions after the person submits the form the first time with errors will result in the checkboxes POSTing no value at all even if they are checked. I can't figure out where the value is getting lost...
Code: ###### student-registration.php ######
<html>
<head>
<title>Registration Form</title>
<link href="loginmodule.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="jquery-1.2.1.pack.js"></script>
<script type="text/javascript">
function carryOver(def,obj) {
var control = document.getElementById(obj);
control.value = def;
}
function disChange() {
if(document.getElementById('hidDiagnostic').style.display=='none') {
document.getElementById('hidDiagnostic').style.display = "block";
}else {
document.getElementById('hidDiagnostic').style.display = "none";
}
}
function lookup(inputString) {
if(inputString.length == 0) {
$('#schoolSystems').hide();
} else {
$.post("schoolsystemlookup-exec.php", {ss: ""+inputString+""}, function(data){
if(data.length >0) {
$('#schoolSystems').show();
$('#schoolSystemsList').html(data);
}
});
}
} // lookup
function fill(thisValue) {
$('#ss').val(thisValue);
setTimeout("$('#schoolSystems').hide();", 200);
}
</script>
</head>
<body>
<?php
session_start();
if( isset($_SESSION['ERRMSG_ARR']) && is_array($_SESSION['ERRMSG_ARR']) && count($_SESSION['ERRMSG_ARR']) >0 ) {
echo '<h1>Error! Form will not be processed till mistakes are fixed</h1>';
echo '<ul class="err">';
foreach($_SESSION['ERRMSG_ARR'] as $msg) {
echo '<li>',$msg,'</li>';
}
echo '</ul>';
unset($_SESSION['ERRMSG_ARR']);
}
?>
<div id="hStudent" style="width:100%; height:50px; background-color:#EAE9E4; color:#FF0000; font-size:40px;">
<b>Basic Student Information</b>
</div>
<form action="studentregistration-exec.php" method="post">
<table>
<tr>
<td>Student First Name:</td>
<td><input type="text" name="stuFName" id="stuFName"/></td>
</tr>
<tr>
<td>Student Last Name:</td>
<td><input type="text" name="stuLName" id="stuLName"/></td>
</tr>
<tr>
<td>Student Grade:</td>
<td><select name="stuGrade" id="stuGrade">
<option value="IP">Infant Program</option>
<option value="PS">Pre-School Program</option>
<option value="KG">K</option>
<option value="01">1</option>
<option value="02">2</option>
<option value="03">3</option>
<option value="04">4</option>
<option value="05">5</option>
<option value="06">6</option>
<option value="07">7</option>
<option value="08">8</option>
<option value="09">9</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
<option value="PG">College</option>
<option value="V">Vocational</option>
<option value="A">Adult Rehabilitation</option>
<option value="OR">Other</option>
</select></td>
</tr>
<tr>
<td>Date of Birth:</td>
<td><select name="bMonth" id="bMonth">
<option value="01">January</option>
<option value="02">February</option>
<option value="03">March</option>
<option value="04">April</option>
<option value="05">May</option>
<option value="06">June</option>
<option value="07">July</option>
<option value="08">August</option>
<option value="09">September</option>
<option value="10">October</option>
<option value="11">November</option>
<option value="12">December</option>
</select>
<select name="bDate" id="bDate">
<?php
for($d = 1; $d <= 31; $d++) {
if($d < 10) { echo "<option value='0$d'>0$d</option>";
} else{ echo "<option value='$d'>$d</option>";}
}
?>
</select>
<select name="bYear" id="bYear">
<?php
for($y = date("Y"); $y >= (date("Y")-110); $y--) {
echo "<option value='$y'>$y</option>";
}
?>
</select></td>
</tr>
<tr>
<td>Address #1:</td>
<td><input type="text" name="stuAddOne" id="stuAddOne"/></td>
</tr>
<tr>
<td>Address #2 (optional):</td>
<td><input type="text" name="stuAddTwo" id="stuAddTwo"/></td>
</tr>
<tr>
<td>City/Zip:</td>
<td><input type="text" name="stuCity" id="stuCity"/>
<input type="number" size=3 maxlength=5 name="stuZip" id="stuZip"/></td>
</tr>
</table>
<div id="hSchool" style="width:100%; height:50px; background-color:#EAE9E4; color:#FF0000; font-size:40px;">
<b>School and Material Information</b>
</div>
<table>
<tr>
<td>School System:</td>
<td><input type="text" onkeyup="lookup(this.value);" name="ss" id="ss" />
<div class="suggestionsBox" id="schoolSystems" style="display: none;">
<img src="upArrow.png" style="position: relative; top: -12px; left: 50px" alt="upArrow" />
<div class="suggestionList" id="schoolSystemsList">
</div>
</div></td>
</tr>
<tr>
<td>Transfer Student: </td>
<td><input type="checkbox" value="-1" name="stuTransfer" id="stuTransfer"/></td>
</tr>
<tr>
<td>Primary Reading Material: </td>
<td><select name="readMaterial" id="readMaterial">
<option value="LP">Large Print</option>
<option value="BR">Braille</option>
<option value="AU">Audio</option>
<option value="ET">Electronic Text</option>
</select></td>
</tr>
<tr>
<td>Individual Education Plan or 504 Plan on file?</td>
<td><select name="iep" id="iep">
<option value="-1">Yes</option>
<option value="0">No</option>
</select></td>
</tr>
<tr>
<td>Date Enrolled in School:</td>
<td><select name="enrMonth" id="enrMonth">
<option value="01">January</option>
<option value="02">February</option>
<option value="03">March</option>
<option value="04">April</option>
<option value="05">May</option>
<option value="06">June</option>
<option value="07">July</option>
<option value="08">August</option>
<option value="09">September</option>
<option value="10">October</option>
<option value="11">November</option>
<option value="12">December</option>
</select>
<select name="enrDate" id="enrDate">
<?php
for($d = 1; $d <= 31; $d++) {
if($d < 10) { echo "<option value='0$d'>0$d</option>";
} else{ echo "<option value='$d'>$d</option>";}
}
?>
</select>
<select name="enrYear" id="enrYear">
<?php
for($y = date("Y"); $y >= (date("Y")-25); $y--) {
echo "<option value='$y'>$y</option>";
}
?>
</select></td>
</tr>
</table>
<div id="hSchool" style="width:100%; height:50px; background-color:#EAE9E4; color:#FF0000; font-size:40px;">
<b>Eligibility</b>
</div>
<table>
<tr>
<td>Print Disabilities:</td>
</tr>
<tr>
<td /><td>Visual Disability:</td>
<td><input type="checkbox" value="-1" onclick="disChange();" name="disVisual" id="disVisual"/></td>
</tr>
<tr>
<td /><td>Reading Disability:</td>
<td><input type="checkbox" value="-1" name="disReading" id="disReading"/></td>
</tr>
<tr>
<td /><td>Physical Disability:</td>
<td><input type="checkbox" value="-1" name="disPhysical" id="disPhysical"/></td>
</tr>
<tbody id="hidDiagnostic" style="display:none;">
<tr>
<td>Right Eye:</td>
<td>20 / <input type="text" name="eyeRight" id="eyeRight"/></td>
</tr>
<tr>
<td>Left Eye:</td>
<td>20 / <input type="text" name="eyeLeft" id="eyeLeft"/></td>
</tr>
</tbody>
</table>
<div id="hAuthorize" style="width:100%; height:50px; background-color:#EAE9E4; color:#FF0000; font-size:40px;">
<b>Authorizing Information</b>
</div>
I certify that the above information is accurate and fully documented:
<table>
<tr>
<td>Name:</td>
<td><input type="text" name="authName" id="authName"/></td>
</tr>
<tr>
<td>Position/Title:</td>
<td><input type="text" name="authTitle" id="authTitle"/></td>
</tr>
<tr>
<td>Phone Number:</td>
<td>(<input type="text" size=1 maxlength=3 name="authArea" id="authArea"/>) <input type="text" size=1 maxlength=3 name="authPhoneOne" id="authPhoneOne"/> - <input type="text" size=2 maxlength=4 name="authPhoneTwo" id="authPhoneTwo"/></td>
</tr>
<tr>
<td>Email:</td>
<td><input type="text" name="authEmail" id="authEmail"/></td>
</tr>
<tr>
<td>Address:</td>
<td><input type="text" name="authAddress" id="authAddress"/></td>
</tr>
<tr>
<td>City/Zip:</td>
<td><input type="text" name="authCity" id="authCity"/> <input type="number" size=3 maxlength=5 name="authZip" id="authZip"/></td>
</tr>
</table>
<input type="submit" value="Submit"/>
</form>
<?php
if( isset($_SESSION['FORM_ARR']) && is_array($_SESSION['FORM_ARR']) && count($_SESSION['FORM_ARR']) >0 ) {
$field_arr = array();
$field_arr[0]="stuFName";
$field_arr[1]="stuLName";
$field_arr[2]="stuGrade";
$field_arr[3]="bMonth";
$field_arr[4]="bDate";
$field_arr[5]="bYear";
$field_arr[6]="stuAddOne";
$field_arr[7]="stuAddTwo";
$field_arr[8]="stuCity";
$field_arr[9]="stuZip";
$field_arr[10]="ss";
$field_arr[11]="stuTransfer";
$field_arr[12]="readMaterial";
$field_arr[13]="iep";
$field_arr[14]="enrMonth";
$field_arr[15]="enrDate";
$field_arr[16]="enrYear";
$field_arr[17]="disVisual";
$field_arr[18]="disReading";
$field_arr[19]="disPhysical";
$field_arr[20]="eyeRight";
$field_arr[21]="eyeLeft";
$field_arr[22]="authName";
$field_arr[23]="authTitle";
$field_arr[24]="authArea";
$field_arr[25]="authPhoneOne";
$field_arr[26]="authPhoneTwo";
$field_arr[27]="authEmail";
$field_arr[28]="authAddress";
$field_arr[29]="authCity";
$field_arr[30]="authZip";
$c=0;
foreach($_SESSION['FORM_ARR'] as $obj) {
echo "<SCRIPT type='text/javascript'>carryOver('" . $obj . "','" . $field_arr[$c] . "');</SCRIPT>";
echo $c . " - " . $obj . "
";
$c++;
}
unset($_SESSION['FORM_ARR']);
}
?>
</body>
</html>Code: ##### studentregistration-exec.php #####
<?php
function session_restart()
{
if (session_name()=='') {
// Session not started yet
session_start();
}
else {
// Session was started, so destroy
session_destroy();
// But we do want a session started for the next request
session_start();
session_regenerate_id();
// PHP < 4.3.3, since it does not put
setcookie(session_name(), session_id());
}
}
//Start session
//session_start();
//Array to store validation errors
$errmsg_arr = array();
//Array to store previous form entries
$form_arr = array();
//Validation error flag
$errflag = false;
require_once('config.php');
$link = mysql_connect(DB_HOST, DBA_USER, DB_PASSWORD);
if(!$link) {
die('Failed to connect to server: ' . mysql_error());
}
$db = mysql_select_db(DBA_DATABASE);
if(!$db) {
die("Unable to select database");
}
//Function to sanitize values received from the form. Prevents SQL injection
function clean($str) {
$str = @trim($str);
if(get_magic_quotes_gpc()) {
$str = stripslashes($str);
}
return mysql_real_escape_string($str);
}
$form_arr[0] = $stuFName = clean($_POST['stuFName']);
$form_arr[1] = $stuLName = clean($_POST['stuLName']);
$form_arr[2] = $stuGrade = clean($_POST['stuGrade']);
$form_arr[3] = $bMonth = clean($_POST['bMonth']);
$form_arr[4] = $bDate = clean($_POST['bDate']);
$form_arr[5] = $bYear = clean(
Calling All PHPFREAKS Blackberry Users
Are you a member of PHPFreaks and have a blackberry? Well RIM just recently released Blackberry Messenger 5.0! What does this mean for you, the user? It means that you have all sorts of cool new
Conditions of info record - Error
When i created GR (901) and PO create automatic my PBXX is obtain the net price of info record but when i Created PO with ME21N the info record is OK
"From field" in PHP email form
I used a wizard to create a PHP email form. I was able to customize it with the exception of the From field. I need the email that is sent to be "From" the email that the sender input.
how to read and write into a word document using php...?
hi,I need,reading and writting into a word document using php.Thank u inadvance,Madhu
explode() function problem maybe
Hi I'm having trouble searching my database. When I type two words in the search field it only searches for the second word. For example: if I typed london zoo , it will only search for zoo.Is this
PHP XML extraction text
I would like to extract an xml text and have that text directly echo(print) out on my web page. Here's the xml i want to extract:http://dblp.uni-trier.de/search/author?xauthor=SchekWhat I
rdns with php
I am trying to build a script that will show all of the different domains that are hosted on the same ip. However when I do a rdns lookup with php only 1 of the domains is returned. How can I make it
help me fix these syntax errors...
I keep getting multiple syntax errors on this script like this one:Parse error: syntax error, unexpected T_ELSE in .../scripts/php/loginform2.php on line 40when I change that line I get another on
Code working in IE but not FireFox
I created a dynamic navigation list for my website based off of a table in my database. The code is working perfectly in IE (I have version 8 on this computer) But it wont work on Firefox. I'm not
Help with PHP Email Script
Hi guys,I'm a newbie to php and need help with the script below:At the moment when I receive the automated email of data, I'm not receiving any information with the form field names I receive blank