Here's the whole code for this page (I replaced personal information by ***) but because all the other form objects work fine, I don't think there's any problem with the form in itself...
And by the way, in the <form action="noticecreation.php" method="post"> line, I can't replace the file name by " $_SERVER[PHP_SELF] ", otherwise, I get an error saying
"Not Found
The requested URL /$_SERVER[PHP_SELF] was not found on this server.
Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request."
??? :-/
<?php
session_name ('YourVisitID');
session_start(); // Start the session.
require_once ('./includes/config.inc.php'); // error handling script
require_once ('./includes/db_connect.php'); // Connects to the database
// If no session value is present, redirects the user:
if (!isset($_SESSION['agent']) OR ($_SESSION['agent'] != md5($_SERVER['HTTP_USER_AGENT'])) ) {
// Start defining the URL:
$url = 'http://' . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']);
// Check for a trailing slash.
if ((substr($url, -1) == '/') OR (substr($url, -1) == '\\') ) {
$url = substr ($url, 0, -1); // Chop off the slash.
}
$url .= '/index.php'; // Add the page.
header("Location: $url");
exit(); // Quit the script.
}
$notice_number = date("YmdHis");
$start_date = "NCR not activated yet";
$project = "***"; //***
if (isset($_POST['submitted'])) { // Handles the form:
// Check for an location:
if ($_POST['location'] <> "NULL") {
$location = $_POST['location'];
} else {
$location = FALSE;
echo '<p><font color="red">Please select a location!</font></p>';
}
// Check for an NCE Category:
if ($_POST['nce_type'] <> "NULL") {
$nce_type = $_POST['nce_type'];
} else {
$nce_type = FALSE;
echo '<p><font color="red">Please select an NCE category!</font></p>';
}
// Check for a nonconformity description:
if ($_POST['non_conformity_desc'] <> "NULL") {
$non_conformity_desc = $_POST['non_conformity_desc'];
} else {
$non_conformity_desc = FALSE;
echo '<p><font color="red">Please describer the nonconformity!</font></p>';
}
if ($location && $nce_type && $non_conformity_desc) { //The required information has been correctly selected:
$notice_type = "1"; //notice_type 1 = notice
$notice_status = "1"; // notice_status 1 = notice created
// Inserts into the db the new created NCR
$query = "INSERT INTO notice (notice_number, notice_type, notice_status, project, originator, location, nce_cat, non_conformity_desc)
VALUES ('$notice_number', '$notice_type', 'notice_status', '$project', '$originator', '$location', '$nce_type', '$non_conformity_desc')";
$result = mysql_query ($query) or trigger_error("Query: $query\n<br />MySQL Error: " . mysql_error() );
if (mysql_affected_rows() == 1) { // If the notice creation ran OK, updates the notice history:
$originator = $_SESSION['user_id']; // Originator's user ID
$modif_date = date("YmdHi"); // Generates the notice modification history time
// Inserts into the db the new created NCR (ncr_type 1 = notice and ncr_status 1 = notice created)
$query = "INSERT INTO notice_history (notice_number, new_status, notice_type, modif_by, modif_date)
VALUES ('$notice_number', 'notice_status', '$notice_type', '$originator', '$modif_date')";
$result = mysql_query ($query) or trigger_error("Query: $query\n<br />MySQL Error: " . mysql_error() );
if (mysql_affected_rows() == 1) { // If the notice history ran OK:
echo "<h3>The notice $notice_number has been correctly created and the Technical Reviewer should receive an email shortly!</h3>";
// sends an automatically generated email to the Technical reviewer.
exit();
} else { // If the notice history did not run OK:
echo '<p><font color="red">You could not create this notice due to a system error. We apologize for any inconvenience.</font></p>';
}
} else { // If the INSERT INTO did not run OK.
echo '<p><font color="red">Error: You could not be create this notice due to a system error. We apologize for any inconvenience.</font></p>';
}
} else { // If one of the required information has NOT been correctly selected:
echo '<p><font color="red">Please try again!</font></p>';
}
mysql_close(); // Close the database connection.
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "[
www.w3.org];
<html xmlns="[
www.w3.org]; xml:lang="en" lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
<title>Notice Creation</title>
<style type="text/css" media="screen">
@import url("./includes/main.css");
</style>
</head>
<body>
<form action="noticecreation.php" method="post">
<table width="100%" border="1" align="center">
<tr>
<td width="15%" rowspan="7" align="center" valign="top"><p align="center"><img src="./images/bcmot.gif" alt="BCMoT" name="BCMoT" width="112" height="97" align="top" id="BCMoT" /></p>
<p align="center">***</p></td>
<td height="85%" colspan="4"><div align="center">
<h2>***</h2>
</div></td>
</tr>
<tr>
<td width="10%" height="30" class="headerboxes">NCR Number</td>
<td width="30%"><input name="notice_number" type="text" readonly="true" value="<?php echo $notice_number; ?>" size="15" maxlength="14" /></td>
<td width="15%" class="headerboxes">Date Opened</td>
<td width="30%"><input name="start_date" type="text" readonly="true" value="<?php echo $start_date; ?>" size="20" maxlength="30" /></td>
</tr>
<tr>
<td width="10%" height="30" class="headerboxes">Project</td>
<td width="30%"><input name="project" type="text" id="project" readonly="true" value="<?php echo $project; ?>" size="32" maxlength="30" /></td>
<td width="15%" class="headerboxes">Concession</td>
<td width="30%"> </td>
</tr>
<tr>
<td width="10%" height="30" class="headerboxes">Originator</td>
<td width="30%"><input name="originator" type="text" readonly="true" value="<?php echo "{$_SESSION['first_name']} {$_SESSION['last_name']}"; ?>" size="32" maxlength="41" /></td>
<td width="15%" class="headerboxes">Response Deadline</td>
<td width="30%"> </td>
</tr>
<tr>
<td width="10%" height="30" class="headerboxes">Audit Item</td>
<td width="30%"> </td>
<td width="15%" class="headerboxes">Location</td>
<td width="30%"><select name="location"><option value="NULL">Choose a Location:</option>
<?php
/* ORIGINAL ONE:
$query = 'SELECT location_id, route_num, direction, begin_km, landmark_desc FROM location ORDER BY begin_km ASC';
$result = mysql_query ($query);
while ($row = mysql_fetch_array ($result, MYSQL_NUM)) {
echo "<option value=\"$row[0]\">$row[3] $row[4]</option>";
}
if($row[0] == $select_val){
echo "<option value=\"$row[0]\" selected=\"selected\">$row[3] $row[4]</option>";
} else {
echo "<option value=\"$row[0]\">$row[3] $row[4]</option>";
}
*/
$query = 'SELECT location_id, route_num, direction, begin_km, landmark_desc FROM location ORDER BY begin_km ASC';
$result = mysql_query ($query);
$location_id = $_POST['location_id'];
while ($row = mysql_fetch_array ($result, MYSQL_NUM)) {
if($row[0] == $select_val){
echo "<option value=\"$row[0]\" selected=\"selected\">$row[3] $row[4]</option>";
} else {
echo "<option value=\"$row[0]\">$row[3] $row[4]</option>";
}
}
?></select></td>
</tr>
<tr>
<td width="10%" height="30" class="headerboxes">Specification</td>
<td width="30%"> </td>
<td width="15%" class="headerboxes">QMS Standard / Procedure</td>
<td width="30%"> </td>
</tr>
<tr>
<td width="10%" height="30" class="headerboxes">NCE Category</td>
<td width="30%"><select name="nce_type"><option value="NULL">Choose an NCE Category:</option>
<?php
$query = 'SELECT nce_type FROM nce_cat ORDER BY nce_type ASC';
$result = mysql_query ($query);
while ($row = mysql_fetch_array ($result, MYSQL_NUM)) {echo "<option value=\"$row[0]\">$row[0]</option>";}
?>
</select></td>
<td width="15%" class="headerboxes">Spec and Clause#</td>
<td width="30%"> </td>
</tr>
<tr>
<td width="15%"><div align="center">
<h3>II) ORIGINATOR</h3>
</div></td>
<td width="85%" colspan="4"><h3>DESCRIPTION OF NON-CONFORMITY:</h3>
<p><textarea name="non_conformity_desc" cols="120" rows="5" id="non_conformity_desc"><?php if (isset($_POST['non_conformity_desc'])) echo $_POST['non_conformity_desc']; ?></textarea></p></td>
</tr>
</table>
<div align="center"><input type="submit" name="submit" value="Create Notice" /></div>
<input type="hidden" name="submitted" value="TRUE" />
</form>
</body>
</html>
Edited 2 time(s). Last edit was four years ago by THYREN.