Newbie help with PHP Mail form

HI everyone,

First post, been lurking for a while, find the board very helpful, but cant seem to find the answer to my particular problem, so thought I would register and ask…

I have a very simple .php mailform to email script (below message) which I have tested on my own server and it works fine. However, when I upload the script to the actual server I need it to be running from, it errors out every time.

You can test the form http://www.provokedesign.net/cgi2/php_email/feedbackform.htm

Which references the following .php form: http://www.provokedesign.net/cgi2/php_email/feedbackform.php

Could this possibly be a server configuration problem?

Your help is very much appreciated guys, so thanks in advance.

Martyn.

Could you provide a bit more detail? Perhaps some specific info about the errors? What messages, what page, etc…

I really don’t want to go and fill out a long form just to see potential errors.

Hi,

Thanks for the response.

In answer to your questions, the error message is the actual ‘error.htm’ page which is referenced in the .php form.

This is the actual .php form:

[code]<?php

// get posted data into local variables, these are required fields…
$EmailFrom = “approval”;
$EmailTo = "[email protected]";
$Subject = “Feedback Form from adecco.linney.com”;
$branchnumber = Trim(stripslashes($_POST[‘branchnumber’]));
$name = Trim(stripslashes($_POST[‘name’]));
$telnumber = Trim(stripslashes($_POST[‘telnumber’]));
$dateandtime = Trim(stripslashes($_POST[‘dateandtime’]));
$rateordersite = Trim(stripslashes($_POST[‘rateordersite’]));
$newsitecomments = Trim(stripslashes($_POST[‘newsitecomments’]));

// validation
$validationOK=true;
if (Trim($rateordersite)=="") $validationOK=false;
if (!$validationOK) {
print “”;
exit;
}

// prepare email body text
$Body = “”;
$Body .= "Branch Number: ";
$Body .= $branchnumber;
$Body .= “n”;
$Body .= “n”;
$Body .= "Name: ";
$Body .= $name;
$Body .= “n”;
$Body .= “n”;
$Body .= "Tel Number: ";
$Body .= $telnumber;
$Body .= “n”;
$Body .= “n”;
$Body .= "Date and Time: ";
$Body .= $dateandtime;
$Body .= “n”;
$Body .= “n”;
$Body .= "Rate Order Site: ";
$Body .= $rateordersite;
$Body .= “n”;
$Body .= “n”;
$Body .= "New Site Comments: ";
$Body .= $newsitecomments;
$Body .= “n”;
$Body .= “n”;
$Body .= "Site Improvement Suggestions: ";
$Body .= $siteimprovementsuggestions;
$Body .= “n”;
$Body .= “n”;
$Body .= "Helpline Assistance Rating: ";
$Body .= $HelplineAssistanceRating;
$Body .= “n”;
$Body .= “n”;
$Body .= "Satisfied With Adecco Line Staff: ";
$Body .= $SatisfiedWithAdeccoLineStaff;
$Body .= “n”;
$Body .= “n”;
$Body .= "Comments About Adecco Support: ";
$Body .= $CommentsAboutAdeccoSupport;
$Body .= “n”;
$Body .= “n”;
$Body .= "Orders Delivered On Time?: ";
$Body .= $orders;
$Body .= “n”;
$Body .= “n”;
$Body .= "Any Issues with Orders: ";
$Body .= $orderissues;
$Body .= “n”;
$Body .= “n”;
$Body .= "Packaged Well? Any Damage Suffered in Transit?: ";
$Body .= $transitcomments;
$Body .= “n”;
$Body .= “n”;
$Body .= "Any Comments Regarding Your Order, or Delivery of Orders?: ";
$Body .= $ordercomments;
$Body .= “n”;
$Body .= “n”;
$Body .= "Any Suggestions on Improving Our Relationship with Adecco Branches?: ";
$Body .= $improvementsuggestions;
$Body .= “n”;
$Body .= “n”;
$Body .= "Any Other Comments You Would Like To Make?: ";
$Body .= $othercomments;
$Body .= “n”;

// send email
$success = mail($EmailTo, $Subject, $Body, “From: <$EmailFrom>”);

// redirect to success page
if ($success){
print “”;
}
else{
print “”;
}
?>
[/code]

Admin Edit: Closed the CODE tag

Well 2 things will re-direct to the ERROR.HTM page. One is if there is an error in sending the email from

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

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

However, are you sure you are getting that far?

What about further Up the page where there is the “VALIDATION” :

 // validation
    $validationOK=true;
    if (Trim($rateordersite)=="") $validationOK=false;
    if (!$validationOK) {
      print "<meta http-equiv="refresh" content="0;URL=error.htm">";
      exit;
    }

Is it actually validating properly? Perhaps a “Re-Direct” to somewhere ELSE for the validation or at least passing it an Error message indicating Why this page was reached.

 print "<meta http-equiv="refresh" content="0;URL=error.htm?msg=ValidataionError">";

Or some other unique id that can then be parsed in the Error Page to determine the reason for the error.

Hi,

Thanks for the help peg110.

I have tried your suggestions, on the error page (enquiryerror.htm) do I need to input a for field to parse the message from the ‘URL=error.htm?msg=ValidataionError">";’ tag?

Yes…

To use my “Example” you could do something like:

// Get the Error message if passed if not... Make it an Unknown error.
$msg = !empty($_GET['msg']) ? trim($_GET['msg']) : "Unknown Error"

//Decide What type of error you have and do something with it.
Switch ($msg) {
   Case "ValidataionError" :
           Echo "THERE was an Error Validating Your Data";
           break;

   Case "SomeOtherError" :
           Echo "THERE was SOME OTHER Error in Your Data";
           break;
   Case "Unknown Error" :
           Echo "THERE was an Unknown Error with Your Data";
           break;
default:
           Echo "THERE was an Unknown Error not covered in other error messages with Your Data";
           break;
}
Sponsor our Newsletter | Privacy Policy | Terms of Service