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 = 'me@gmail.com';
$Subject = 'Customer Questionnaire';
$EmailFrom = 'response@clients.net'
$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
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
Share on other sites

add

 

ini_set('display_errors', 1);
ini_set('error_reporting', E_ALL);

 

Straight after your php tag '<?php'

 

Also test the mail function:

 

<?php
if(mail(~details}))
{
echo 'sent';
}
else
{
echo 'not sent';
}

Link to comment
Share on other sites

my code now looks like

 

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

$EmailTo = 'me@gmail.com';
$Subject = 'Customer Questionnaire';
$EmailFrom = 'response@client.net'
$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
Share on other sites

$EmailFrom = 'response@client.net'

 

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
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 = 'me@gmail.com';
$Subject = 'Customer Questionnaire';
$EmailFrom = 'response@client.net';
$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
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 erkzh@yahoo.com.

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


$subject = 'Website Enquiry';                // Subject of email sent to you.
$emailadd = 'me@gmail.com';        // 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
Share on other sites

If there's other working, why dont you start again...

 

<?php
if(mail('youremail', 'test', 'test body'))
{
echo 'sent';
}
else
{
echo 'not sent';
}
?>

 

If it works keep adding, if/when you get stuck, report back!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.