Hi,
I got a sort of form validation script here, but it doesnt work. it seems to go straight to the next page and doesnt say if there was an error. Is there a simpler way to do this validation? And why does it not pick up wrong data entered?
if ((isset($_POST["MM_update"])) == "NW") {
$DP = $_POST['DP'];
$DR = $_POST['DR'];
$DF = $_POST['DF'];
$PPN = $_POST['PPN'];
$Model = $_POST['Model'];
$Serial = $_POST['Serial'];
$EN = $_POST['EN'];
$Hours = $_POST['Hours'];
$Customer = $_POST['Customer'];
$Application = $_POST['Application'];
$Material = $_POST['Material'];
$JL = $_POST['JL'];
$status = $_POST['status'];
$error = array('');
if (!ctype_alnum($PPN)) {array_push ($error,"ppn");}
if (!ctype_alnum($Model)) {array_push ($error,"model");}
if (!ctype_alnum($Serial)) {array_push ($error,"serial");}
if (!ctype_alnum($EN)) {array_push ($error,"en");}
if (!ctype_digit($Hours)){array_push ($error,"hours");}
if (!ctype_alnum($Customer)) {array_push ($error,"customer");}
if (!ctype_alnum($Application)) {array_push ($error,"application");}
if (!ctype_alnum($Material)) {array_push ($error,"material");}
if (!ctype_alnum($JL)) {array_push ($error,"jl");}
//foreach ($error as $key => $th){
if ($th !== "ppn" || "model" || "serial" || "en" || "hours" || "customer" || "application" || "material" || "jl"){
$update_w = "UPDATE Warrants SET DPrepared='$DP', DRepared='$DR', DFailure='$DF', PPartnumber='$PPN', Model='$Model', FullSN='$Serial',
ENumber='$EN', Hours='$Hours', Customer='$Customer', Application='$Application', Material='$Material', JLocation='$JL', Status='$status'
WHERE RefNumber='$ref_value'";
$Result = mysql_query($update_w, $localhost) or die(mysql_error());
$update_w = "dwcc.php";
if (isset($_SERVER['QUERY_STRING'])) {
$update_w .= (strpos($update_w, '?')) ? "&" : "?";
$update_w .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $update_w));
}else{
$message = 1;
//$URL="dwc.php";
//header ("Location: $URL");
}
}
Thanks for any advice.