Jump to content

Mail Form Help


insomnia

Recommended Posts

So, I'm making what should be a simple form, and at 3:45am, I'm stuck. When I hit submit on the front end, it goes to the contact.php file and displays it as a blank page. Funny thing is that after a whole bunch of fiddling, I got it right on one of its incarnations, but it got caught in my spam filter, which I didn't discover until I made a whole load of changes, breaking it again. Any help, or belittling me and then pointing me in the right direction would be greatly appreciated.

<?php

$EmailTo = '[email protected]';
$Subject = 'Customer Questionnaire';
$EmailFrom = '[email protected]'
$likelytorefer = Trim(stripslashes($_POST['likelytorefer']));
$continuebusiness = Trim(stripslashes($_POST['continuebusiness']));
$satisfiedrepairs = Trim(stripslashes($_POST['satisfiedrepairs']));
$satisfiedservice = Trim(stripslashes($_POST['satisfiedservice']));
$satisfiedresponse = Trim(stripslashes($_POST['satisfiedresponse']));
$satisfiedadministration = Trim(stripslashes($_POST['satisfiedadministration']));
$ease = Trim(stripslashes($_POST['ease']));
$website = Trim(stripslashes($_POST['website']));
$knowledge = Trim(stripslashes($_POST['knowledge']));
$recommendation = Trim(stripslashes($_POST['recommendation']));
$cost = Trim(stripslashes($_POST['cost']));
$service = Trim(stripslashes($_POST['service']));
$improve = Trim(stripslashes($_POST['improve']));
$reason = Trim(stripslashes($_POST['reason']));

$Body = "";
$Body .= "How likely the respondent is to recommend Company: ";
$Body .= $likelytorefer;
$Body .= "\n";
$Body .= "How likely the respondent is to continue business with Company:";
$Body .= $continuebusiness;
$Body .= "\n";
$Body .= "How satisfied the respondent is with repairs: ";
$Body .= $satisfiedrepairs;
$Body .= "\n";
$Body .= "How satisfied the respondent is with service: ";
$Body .= $satisfiedservice;
$Body .= "\n";
$Body .= "How satisfied the respondent is with response times: ";
$Body .= $satisfiedresponse;
$Body .= "\n";
$Body .= "How satisfied the respondent is with administration service: ";
$Body .= $satisfiedadministration;
$Body .= "\n";
$Body .= "Ease in Dealings: ";
$Body .= $ease;
$Body .= "\n";
$Body .= "Information on Website: ";
$Body .= $website;
$Body .= "\n";
$Body .= "Industry Knowledge: ";
$Body .= $knowledge;
$Body .= "\n";
$Body .= "Recommendation: ";
$Body .= $recommendation;
$Body .= "\n";
$Body .= "Cost Efficency: ";
$Body .= $cost;
$Body .= "\n";
$Body .= "Service: ";
$Body .= $service;
$Body .= "\n";
$Body .= "How the respondent thinks Company can improve: ";
$Body .= $improve;
$Body .= "\n";
$Body .= "Why the respondent uses Company: ";
$Body .= $reason;
$Body .= "\n";


mail($EmailTo, $Subject, $Body, 'From: '.$EmailFrom.'');
echo '<meta http-equiv=\"refresh\" content=\"0;URL=thankyou.html">';
?>

Link to comment
https://forums.phpfreaks.com/topic/165222-mail-form-help/
Share on other sites

I'm guessing you haven't got error reporting turned on;

 

$satisfiedservice = Trim(stripslashes($_POST[['satisfiedservice']));

$satisfiedresponse = Trim(stripslashes($_POST[['satisfiedresponse']));

$satisfiedadministration = Trim(stripslashes($_POST[['satisfiedadministration']));

$ease = Trim(stripslashes($_POST[['ease']));

$website = Trim(stripslashes($_POST[['website']));

$knowledge = Trim(stripslashes($_POST[['knowledge']));

$recommendation = Trim(stripslashes($_POST[['recommendation']));

$cost = Trim(stripslashes($_POST[['cost']));

$service = Trim(stripslashes($_POST[['service']));

$improve = Trim(stripslashes($_POST[['improve']));

$reason = Trim(stripslashes($_POST[['reason']));

 

Most of you're post arrays have two openning square brackets.

 

[[

 

should be

 

[

Link to comment
https://forums.phpfreaks.com/topic/165222-mail-form-help/#findComment-871267
Share on other sites

my code now looks like

 

<?php
ini_set('display_errors', 1);
ini_set('error_reporting', E_ALL);

$EmailTo = '[email protected]';
$Subject = 'Customer Questionnaire';
$EmailFrom = '[email protected]'
$likelytorefer = Trim(stripslashes($_POST['likelytorefer']));
$continuebusiness = Trim(stripslashes($_POST['continuebusiness']));
$satisfiedrepairs = Trim(stripslashes($_POST['satisfiedrepairs']));
$satisfiedservice = Trim(stripslashes($_POST['satisfiedservice']));
$satisfiedresponse = Trim(stripslashes($_POST['satisfiedresponse']));
$satisfiedadministration = Trim(stripslashes($_POST['satisfiedadministration']));
$ease = Trim(stripslashes($_POST['ease']));
$website = Trim(stripslashes($_POST['website']));
$knowledge = Trim(stripslashes($_POST['knowledge']));
$recommendation = Trim(stripslashes($_POST['recommendation']));
$cost = Trim(stripslashes($_POST['cost']));
$service = Trim(stripslashes($_POST['service']));
$improve = Trim(stripslashes($_POST['improve']));
$reason = Trim(stripslashes($_POST['reason']));

$Body = "";
$Body .= "How likely the respondent is to recommend Company: ";
$Body .= $likelytorefer;
$Body .= "\n";
$Body .= "How likely the respondent is to continue business with Company:";
$Body .= $continuebusiness;
$Body .= "\n";
$Body .= "How satisfied the respondent is with repairs: ";
$Body .= $satisfiedrepairs;
$Body .= "\n";
$Body .= "How satisfied the respondent is with service: ";
$Body .= $satisfiedservice;
$Body .= "\n";
$Body .= "How satisfied the respondent is with response times: ";
$Body .= $satisfiedresponse;
$Body .= "\n";
$Body .= "How satisfied the respondent is with administration service: ";
$Body .= $satisfiedadministration;
$Body .= "\n";
$Body .= "Ease in Dealings: ";
$Body .= $ease;
$Body .= "\n";
$Body .= "Information on Website: ";
$Body .= $website;
$Body .= "\n";
$Body .= "Industry Knowledge: ";
$Body .= $knowledge;
$Body .= "\n";
$Body .= "Recommendation: ";
$Body .= $recommendation;
$Body .= "\n";
$Body .= "Cost Efficency: ";
$Body .= $cost;
$Body .= "\n";
$Body .= "Service: ";
$Body .= $service;
$Body .= "\n";
$Body .= "How the respondent thinks Company can improve: ";
$Body .= $improve;
$Body .= "\n";
$Body .= "Why the respondent uses Company: ";
$Body .= $reason;
$Body .= "\n";

mail($EmailTo, $Subject, $Body, 'From: '.$EmailFrom.'');
echo '<meta http-equiv=\"refresh\" content=\"0;URL=thankyou.html">';

if(mail($EmailTo, $Subject, $Body, 'From: '.$EmailFrom.''}))
{
echo 'sent';
}
else
{
echo 'not sent';
}

?>

Link to comment
https://forums.phpfreaks.com/topic/165222-mail-form-help/#findComment-871313
Share on other sites

$EmailFrom = '[email protected]'

 

missing semi-colon

mail($EmailTo, $Subject, $Body, 'From: '.$EmailFrom.'');
echo '<meta http-equiv=\"refresh\" content=\"0;URL=thankyou.html">';

if(mail($EmailTo, $Subject, $Body, 'From: '.$EmailFrom.''}))
{
echo 'sent';
}
else
{
echo 'not sent';
}

 

should be

 

if(mail($EmailTo, $Subject, $Body, 'From: '.$EmailFrom.''}))
{
echo '<meta http-equiv=\"refresh\" content=\"0;URL=thankyou.html">';
}
else
{
echo 'not sent';
}

Link to comment
https://forums.phpfreaks.com/topic/165222-mail-form-help/#findComment-871326
Share on other sites

Ah, stupid me.

Still coming up blank. My code is now:

<?php
ini_set('display_errors', 1);
ini_set('error_reporting', E_ALL);

$EmailTo = '[email protected]';
$Subject = 'Customer Questionnaire';
$EmailFrom = '[email protected]';
$likelytorefer = Trim(stripslashes($_POST['likelytorefer']));
$continuebusiness = Trim(stripslashes($_POST['continuebusiness']));
$satisfiedrepairs = Trim(stripslashes($_POST['satisfiedrepairs']));
$satisfiedservice = Trim(stripslashes($_POST['satisfiedservice']));
$satisfiedresponse = Trim(stripslashes($_POST['satisfiedresponse']));
$satisfiedadministration = Trim(stripslashes($_POST['satisfiedadministration']));
$ease = Trim(stripslashes($_POST['ease']));
$website = Trim(stripslashes($_POST['website']));
$knowledge = Trim(stripslashes($_POST['knowledge']));
$recommendation = Trim(stripslashes($_POST['recommendation']));
$cost = Trim(stripslashes($_POST['cost']));
$service = Trim(stripslashes($_POST['service']));
$improve = Trim(stripslashes($_POST['improve']));
$reason = Trim(stripslashes($_POST['reason']));

$Body = "";
$Body .= "How likely the respondent is to recommend Company: ";
$Body .= $likelytorefer;
$Body .= "\n";
$Body .= "How likely the respondent is to continue business with Company:";
$Body .= $continuebusiness;
$Body .= "\n";
$Body .= "How satisfied the respondent is with repairs: ";
$Body .= $satisfiedrepairs;
$Body .= "\n";
$Body .= "How satisfied the respondent is with service: ";
$Body .= $satisfiedservice;
$Body .= "\n";
$Body .= "How satisfied the respondent is with response times: ";
$Body .= $satisfiedresponse;
$Body .= "\n";
$Body .= "How satisfied the respondent is with administration service: ";
$Body .= $satisfiedadministration;
$Body .= "\n";
$Body .= "Ease in Dealings: ";
$Body .= $ease;
$Body .= "\n";
$Body .= "Information on Website: ";
$Body .= $website;
$Body .= "\n";
$Body .= "Industry Knowledge: ";
$Body .= $knowledge;
$Body .= "\n";
$Body .= "Recommendation: ";
$Body .= $recommendation;
$Body .= "\n";
$Body .= "Cost Efficency: ";
$Body .= $cost;
$Body .= "\n";
$Body .= "Service: ";
$Body .= $service;
$Body .= "\n";
$Body .= "How the respondent thinks Company can improve: ";
$Body .= $improve;
$Body .= "\n";
$Body .= "Why the respondent uses Company: ";
$Body .= $reason;
$Body .= "\n";

if(mail($EmailTo, $Subject, $Body, 'From: '.$EmailFrom.''}))
{
echo '<meta http-equiv=\"refresh\" content=\"0;URL=thankyou.html">';
}
else
{
echo 'not sent';
}

?>

Link to comment
https://forums.phpfreaks.com/topic/165222-mail-form-help/#findComment-871334
Share on other sites

would it help to mention that the other mailing script they have is currently working just fine? I can use it as a last resort when I get lazy, but the email it produces isn't as neat as the one that would be produced from mine.

 

the code for that one is:

<?php

// Simple Form Script
// Copyright (C) 2005  Eric Zhang
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// Please send bugs/questions to [email protected].

//--------------------------Set these paramaters--------------------------


$subject = 'Website Enquiry';                // Subject of email sent to you.
$emailadd = '[email protected]';        // Your email address. This is where the form information will be sent.
$url = 'http://www.form1.com.au/thankyou.html';               // Where to redirect after form is processed.
$req = '1';                                  // Makes all fields required. If set to '1' no field can not be empty. If set to '0' any or all fields can be empty.

// --------------------------Do not edit below this line--------------------------
$text = "Results from form:\n\n";       
$space = '  ';
$line = '
';
foreach ($_POST as $key => $value)
{
if ($req == '1')
{
	if ($value == '')
	{echo "$key is empty";die;}
}
$j = strlen($key);
	if ($j >= 20)
	{echo "Name of form element $key cannot be longer than 20 characters";die;}
$j = 20 - $j;
	for ($i = 1; $i <= $j; $i++)
	{$space .= ' ';}
$value = str_replace('\n', "$line", $value);
$conc = "{$key}:$space{$value}$line";
$text .= $conc;
$space = '  ';
}
mail($emailadd, $subject, $text, 'From: '.$emailadd.'');
echo '<META HTTP-EQUIV=Refresh CONTENT="0; URL='.$url.'">';
?>

Link to comment
https://forums.phpfreaks.com/topic/165222-mail-form-help/#findComment-871363
Share on other sites

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.