Jump to content

[SOLVED] PHP script keeps generating an error message


fatmikey

Recommended Posts

Hope you can help...I have this script that at some point used to work but I did somthing and now it won't work, it keeps generating an error condition.  Hope you can help me figure this out, I have a simple input form in the front end which calls this PHP script when the user hits submit, here is the script:

 


<?php
// get posted data into local variables
$Email = Trim(stripslashes($_POST['Email'])); 
$EmailTo = "[email protected], [email protected]";
$Subject = "Registration";
$FirstName = Trim(stripslashes($_POST['FirstName'])); 
$LastName = Trim(stripslashes($_POST['LastName'])); 
$Telephone = Trim(stripslashes($_POST['Telephone'])); 
$Address = Trim(stripslashes($_POST['Address'])); 
$City = Trim(stripslashes($_POST['City'])); 
$Province = Trim(stripslashes($_POST['Province'])); 
$PostalCode = Trim(stripslashes($_POST['PostalCode'])); 
$Class = Trim(stripslashes($_POST['Class']));
$Level = Trim(stripslashes($_POST['Level']));
$Day = Trim(stripslashes($_POST['Day']));
$How = Trim(stripslashes($_POST['How']));
$Comments = Trim(stripslashes($_POST['Comments']));

// validation
$validationOK=true;
if (Trim($Email)=="") {
    print "<meta http-equiv=\"refresh\" content=\"0;URL=error1.htm\">";
    exit;
} else {
    $validationOK=true;;
}
if (!preg_match("/\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/", $Email)) {
    print "<meta http-equiv=\"refresh\" content=\"0;URL=error1.htm\">";
exit;
} else {
    $validationOK=true;
}
if (Trim($Email)=="") {
    print "<meta http-equiv=\"refresh\" content=\"0;URL=error1.htm\">";
    exit;
} else {
    $validationOK=true;
}
if (strlen($Telephone) < 10) {
    print "<meta http-equiv=\"refresh\" content=\"0;URL=error2.htm\">";
    exit;
} else {
    $validationOK=true;
}
if (Trim($FirstName)=="") {
    print "<meta http-equiv=\"refresh\" content=\"0;URL=error3.htm\">";
    exit;
} else {
    $validationOK=true;
}
if (Trim($LastName)=="") {
    print "<meta http-equiv=\"refresh\" content=\"0;URL=error4.htm\">";
    exit;
} else {
    $validationOK=true;
}
if (!$validationOK) {
print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
exit;
}

// prepare email body text
$Body = "";
$Body .= "First: ";
$Body .= $FirstName;
$Body .= "\n";
$Body .= "Last: ";
$Body .= $LastName;
$Body .= "\n";
$Body .= "Telephone: ";
$Body .= $Telephone;
$Body .= "\n";
$Body .= "Email: ";
$Body .= $Email;
$Body .= "\n";
$Body .= "Address: ";
$Body .= $Address;
$Body .= "\n";
$Body .= "City: ";
$Body .= $City;
$Body .= "\n";
$Body .= "Province: ";
$Body .= $Province;
$Body .= "\n";
$Body .= "PostalCode: ";
$Body .= $PostalCode;
$Body .= "\n";
$Body .= "Class: ";
$Body .= $Class;
$Body .= "\n";
$Body .= "Level: ";
$Body .= $Level;
$Body .= "\n";
$Body .= "Day: ";
$Body .= $Day;
$Body .= "\n";
$Body .= "How: ";
$Body .= $How;
$Body .= "\n";
$Body .= "Comments: ";
$Body .= $Comments;
$Body .= "\n";

if ($Class == "Workshop") {
    mail($EmailTo, $Subject, $Body, "From: <$Email>");
    print "<meta http-equiv=\"refresh\" content=\"0;URL=checkout.htm\">";
    exit;
}

// send email 
$success = mail($EmailTo, $Subject, $Body, "From: <$Email>");

// redirect to success page 
if ($success){
print "<meta http-equiv=\"refresh\" content=\"0;URL=thankyou.htm\">";
}
else{
print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
}

?>


 

The online form is here www.ottawapolefitness.com/test/registration.htm

 

Not sure if this is relevant but here is the output from the error_log on the host:

 

[29-Sep-2008 16:35:52] PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/local/lib/php/extensions/no-debug-zts-20060613/mysql.so' - /usr/local/lib/php/extensions/no-debug-zts-20060613/mysql.so: Undefined symbol "core_globals" in Unknown on line 0

 

Thanks, I put the enclosed the code.

 

The problem with this script is it keeps jumping to the error on the very last print statement.  No matter how I compete the online form and after the validation it always calls the error.htm page.

 

There is no actual error message, it's just the code is acting up.

 

Mikey

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.