Click to See Complete Forum and Search --> : checkfields


Progess
07-11-2008, 10:32 AM
Here is the code and it works - all I want to do is say if the $AccessTypeID == 8 than do the first error below StaffType otherwise do the rest. It works until I put the if statement in and than does not. Help please - to much time is being wasted on this.

if ($_POST['Access']) {
foreach($_POST['Access'] as $AccessTypeID=>$Access) {
$InsertQuery->Query("insert into UserModules2 (UserID, ModuleID) values ('" . $InsertID . "', '$AccessTypeID')");


// Send email to pharmacy if omnicell is checked

if ($AccessTypeID == 8) {
$AccessTypeEight = $AccessTypeID;
$StaffType = $_POST['StaffType'];


$Name = $_POST['FirstName'] . " " . $_POST['LastName'];
// $StaffType = $_POST['StaffType'];
$PositionQuery = new MyQuery($dbh);
$PositionQuery->Query("select JobTitle from JobTitles where JobTitleID = '$_POST[JobTitleID]'");
$PositionData = $PositionQuery->NextRecord();

SendMail("ekeck@elih.org", "postmaster@elih.org", "New Account Signup
for OmniCell", "A new account has been created that requires access to the
omnicell system. Name: $Name\r\nUsername: $UserName\r\nPosition: $PositionData[JobTitle]\r\nStaff Type: $StaffType\r\n","","");

} //if ($AccessTypeID == 8)

} // foreach($_POST['Access'] as $AccessTypeID=>$Access)
} // if ($_POST['Access'])
} // if (!$InsertID)


if ($_POST['Access']) {
foreach($_POST['Access'] as $AccessTypeID=>$Access) {
$InsertQuery->Query("insert into UserModules2 (UserID, ModuleID) values ('" . $InsertID . "', '$AccessTypeID')");


// Send email if option is checked

if ($AccessTypeID == 8) {
$AccessTypeEight = $AccessTypeID;
$StaffType = $_POST['StaffType'];


$Name = $_POST['FirstName'] . " " . $_POST['LastName'];
// $StaffType = $_POST['StaffType'];
$PositionQuery = new MyQuery($dbh);
$PositionQuery->Query("select JobTitle from JobTitles where JobTitleID = '$_POST[JobTitleID]'");
$PositionData = $PositionQuery->NextRecord();

SendMail("blah@blah", "blah@Blah", "New Account Signup
for Account type ", "A new account has been created that requires access to the
this system. Name: $Name\r\nUsername: $UserName\r\nPosition: $PositionData[JobTitle]\r\nStaff Type: $StaffType\r\n","","");

Here is my error checking that works- the code is below the above code later in the program

<SCRIPT LANGUAGE="JavaScript">
function CheckFields() {

var Errors = "";

Errors += document.SignupForm.StaffType.value == "--" ? "You did not select a Staff Type.\n" : "";
Errors += document.SignupForm.FirstName.value == "" ? "You did not enter the first name.\n" : "";
Errors += document.SignupForm.LastName.value == "" ? "You did not enter the last name.\n" : "";
Errors += document.SignupForm.JobTitleID.value == "" ? "You did not select a job title.\n" : "";
Errors += document.SignupForm.DepartmentID.value == "" ? "You did not select a department.\n" : "";

if (Errors != "") {
alert(Errors);
return false;
} else {
return true;
}

}

</SCRIPT>

Fang
07-11-2008, 11:17 AM
Which if statement? Is this a php or JavaScript question?

Progess
07-11-2008, 11:34 AM
It is a combination

the for loop is in Php but the error handling is in javascript. I have inherited the code and just trying to make a change to it.

all help is appreciated.