Jump to content

New to PHP....processor.php file to process online form


junebug8

Recommended Posts

I have a online html form that uses a processor.php file to process the information and send it via email. Below is the code from the processor.php file. Can somebody tell me if the code is correct?

 

<?php

 

$where_form_is="http://".$_SERVER['SERVER_NAME'].strrev(strstr(strrev($_SERVER['PHP_SELF']),"/"));

 

// Checkbox handling

$field_5_opts = $_POST['field_5'][0].",". $_POST['field_5'][1].",". $_POST['field_5'][2].",". $_POST['field_5'][3];

 

mail("[email protected]","phpFormGenerator - Form submission","Form data:

 

How do you rate the helpfulness of Weir Specialty Pumps' employees?: " . $_POST['field_1'] . "

How do we perform when it comes to fulfulling quote requests?: " . $_POST['field_2'] . "

Please rate the quality of our products as you receive them?: " . $_POST['field_3'] . "

Do the responses and actions of your Regional Sales Manager match your expectations?: " . $_POST['field_4'] . "

In what way could our sales support most improve? (Check all that apply.): $field_5_opts

: " . $_POST['field_6'] . "

Name:: " . $_POST['field_7'] . "

Company:: " . $_POST['field_8'] . "

E-mail:: " . $_POST['field_9'] . "

Comments:: " . $_POST['field_10'] . "

 

 

powered by phpFormGenerator.

");

 

include("confirm.html");

 

?>

It seems to work, but I never receive a email with the processed information. I was getting a function.mail error but have since resolved that. I believe it is sending the email, but I'm not sure if I have the recipient field correctly formatted.

Here's the error I was receiving, and have since fixed, I think!  ;D I'm not getting this error any more.

 

Warning: mail() [function.mail]: "sendmail_from" not set in php.ini or custom "From:" header missing in D:\Wild\www\envirotechslc.com\survey\tempFiles\form1658\processor.php on line 26"

 

I fixed it by making modifications to my mail function section of the php.ini file.

Ok... well the only thing I can sugest would be to send some additional headers aswell. Some mail servers don't like recieving your mail otherwise.

 

<?php

$where_form_is="http://".$_SERVER['SERVER_NAME'].strrev(strstr(strrev($_SERVER['PHP_SELF']),"/"));

// Checkbox handling
$field_5_opts = $_POST['field_5'][0].",". $_POST['field_5'][1].",". $_POST['field_5'][2].",". $_POST['field_5'][3];

$to = "[email protected]";
$subject = "phpFormGenerator - Form submission";
$message = "Form data:

How do you rate the helpfulness of Weir Specialty Pumps' employees?: " . $_POST['field_1'] . " 
How do we perform when it comes to fulfulling quote requests?: " . $_POST['field_2'] . " 
Please rate the quality of our products as you receive them?: " . $_POST['field_3'] . " 
Do the responses and actions of your Regional Sales Manager match your expectations?: " . $_POST['field_4'] . " 
In what way could our sales support most improve? (Check all that apply.): $field_5_opts
: " . $_POST['field_6'] . " 
Name:: " . $_POST['field_7'] . " 
Company:: " . $_POST['field_8'] . " 
E-mail:: " . $_POST['field_9'] . " 
Comments:: " . $_POST['field_10'] . " 


powered by phpFormGenerator.
";

$headers = 'From: [email protected]' . "\r\n" .
    'Reply-To: [email protected]' . "\r\n" .
    'X-Mailer: PHP/' . phpversion();

if (mail($to, $subject, $message, $headers)) {
  include "confirm.html";
} else {
  echo "mail failed to send";
}

?>

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.