I have a 2-page table where the data from that table will then be inserted into another 2-page table and also inserted into the MySQL database. Everything inserts into the database if all fields have something entered into the table. However, if I enter only the first few fields (Lastname, Firstname, StudentID…which will sometimes be the case), nothing gets inserted into the db at all.
Of note, Lastname, Firstname, StudentID and Date all appear in the first few fields of both forms. Date is pre-populated to today’s date.
Can anyone give me any idea why this would happen? Any help is greatly appreciated!
Here is my insert code.[php]
include "MySQLConnector.txt";
// Get the data from the form:
$Lastname = trim($_REQUEST[‘lastname’]);
$Firstname = trim($_REQUEST[‘firstname’]);
$StudentID = trim($_REQUEST[‘studentid’]);
$Credtran = trim($_REQUEST[‘credtran’]);
$Credleft = trim($_REQUEST[‘credleft’]);
$Major = trim($_REQUEST[‘major’]);
$Comments = trim($_REQUEST[‘comments’]);
$Advisorlast = trim($_REQUEST[‘advisorlast’]);
$Advisorfirst = trim($_REQUEST[‘advisorfirst’]);
$Date = trim($_REQUEST[‘date’]);
if (isset($_REQUEST['rdoPrereq'])) {
$Prereq = $_REQUEST['rdoPrereq'];
if ($Prereq == 1) {
} elseif ($Prereq == 2) {
}
} else {
$Prereq = NULL;
}
// Echo back the data from the form to be sure it’s coming back
/*
echo ’
echo ’
echo ’
echo ’
echo ’
echo ’
echo ’
echo ’
echo ’
echo ’
echo ’
*/
$query = "INSERT INTO finaidevaluation (FormID, Lastname, Firstname, StudentID, Credtran, Credleft, Major, Comments, Advisorlast, Advisorfirst, Date, Prereq)
VALUES (NULL, '" . $Lastname . "', '" . $Firstname . "', '" . $StudentID . "', '" . $Credtran . "', '" . $Credleft . "', '" . $Major . "', '" . $Comments . "', '" . $Advisorlast . "', '" . $Advisorfirst . "', '" . $Date . "', '" . $Prereq. "')" ;
mysqli_query($dbc,$query);
mysqli_close($dbc);
?>
Academic Evaluation <script type="text/javascript">
function printpage()
{
window.print()
}
</script>
<style type="text/css">.break { page-break-before: always; }</style>
<?php
$Lastname = $_REQUEST['lastname'];
$Firstname = $_REQUEST['firstname'];
$StudentID = $_REQUEST['studentid'];
$Date = $_REQUEST['date'];
$Credtran = $_REQUEST['credtran'];
$Credleft = $_REQUEST['credleft'];
$Major = $_REQUEST['major'];
$Comments = $_POST['comments'];
$Advisorfirst = $_REQUEST['advisorfirst'];
$Advisorlast = $_REQUEST['advisorlast'];
if (isset($_REQUEST['rdoPrereq'])) {
$Prereq = $_REQUEST['rdoPrereq'];
if ($Prereq == 1) {
$Prereq = "Yes";
} elseif ($Prereq == 2) {
$Prereq = "No";
}
} else {
$Prereq = "";
}[/php]