Jump to content

Help with PHP Auto Response Form


codenoobie

Recommended Posts

Hi everyone. I'm new here and I'm having issues with a PHP form. I am trying to send an auto response to the client, as well as the form results to myself. I have used the code below. The problem is that both the response and the results are being sent to the client. What could I be doing wrong? 

 

<?php
//--------------------------Set these paramaters--------------------------

// Subject of email sent to you.
$subject = 'Internet Request';

// Your email address. This is where the form information will be sent.
$emailadd = 'myemail@comcast.net';

// Where to redirect after form is processed.
$url = 'http://www.butneveragain.org/info/thankyou.html';

// 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.
$req = '0';

// Email address put into Email Field

$email_field = $_POST["Email"]; 

// --------------------------Do not edit below this line--------------------------
$auto_respond_subject = 'TEAM:BARIATRICS Informational Packet Request';
$auto_respond_body = "Thank you for requesting your free TEAM:BARIATRICS Informational Packet. \n
You should recieve your packet within 5-10 business days.\n If you would like additional information, call 574.537.TEAM or visit us online at www.butneveragain.org.";
mail($email_field, $auto_respond_subject, $auto_respond_body);
$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($email_field, $subject, $text, "From: TEAM:BARIATRICS");
echo '<META HTTP-EQUIV=Refresh CONTENT="0; URL='.$url.'">';
?>

Link to comment
Share on other sites

Also, here is my form code:

    <div class="mainContentInfo">
        <img src="../images/info.jpg" width="467" height="14" style="padding-top:20px;"/><br/><br/>
        <span class="copy">To get your Informational Packet, simply fill out the form below or call 574.537.TEAM.</span>
        <p>
        <form id="form1" name="form1" method="post" action="http://www.butneveragain.org/info/mailer.php">
  Name:<label>
        <input name="Name" type="text" class="style1" id="Name" size="30" />
      </label><br/>
      
      Email:<label>
        <input name="Email" type="text" class="style1" id="Email" size="30" />
      </label><br/>
        <label>
        <input name="Submit2" type="reset" class="style1" value="Reset" />
        <input name="Submit" type="submit" class="style1" value="Submit" />
      
</form>
                                             </p>
                                             </div>

Link to comment
Share on other sites

Ok, I'm in trouble here. I'm going to have to really learn PHPMailer as soon as I can. But, I'm really under the gun timewise (I'm pregnant and due tomorrow - if I don't get this site done by the time this baby comes I'm in real trouble with my boss.) Is there anyway to add headers to this code that will customize the "from" email address to say "TEAM:BARIATRICS" instead of "ghsfiles@box394.bluehost.com" easily? I can't figure it out without help. I've been trying to all day and I'm so new at this I'm not having luck at all:

 

<?php
//--------------------------Set these paramaters--------------------------

// Subject of email sent to you.
$subject = 'TEAM:BARIATRICS Informational Packet Request';

// Your email address. This is where the form information will be sent.
$emailadd = 'aubreyburkhart@comcast.net';


// Where to redirect after form is processed.
$url = 'http://www.butneveragain.org/info/thankyou.html';

// 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.
$req = '0';

// Email address put into Email Field

$email_field = $_POST["Email"]; 





// --------------------------Do not edit below this line--------------------------
$auto_respond_subject = 'TEAM:BARIATRICS Informational Packet Request';
$auto_respond_body = "Thank you for requesting your free TEAM:BARIATRICS Informational Packet. \n
You should recieve your packet within 5-10 business days.\n If you would like additional information, call 574.537.TEAM or visit us online at www.butneveragain.org.";
mail($email_field, $auto_respond_subject, $auto_respond_body);
$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: Online Request");

echo '<META HTTP-EQUIV=Refresh CONTENT="0; URL='.$url.'">';


?>

Link to comment
Share on other sites

Thats the most you can do without PHP mailer

 

<?php
//--------------------------Set these paramaters--------------------------

// Subject of email sent to you.
$subject = 'TEAM:BARIATRICS Informational Packet Request';

// Your email address. This is where the form information will be sent.
$emailadd = 'aubreyburkhart@comcast.net';


// Where to redirect after form is processed.
$url = 'http://www.butneveragain.org/info/thankyou.html';

// 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.
$req = '0';

// Email address put into Email Field

$email_field = $_POST["Email"]; 

$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

// Additional headers
$headers .= 'From: TEAM:BARIATRICS <ghsfiles@box394.bluehost.comcom>';




// --------------------------Do not edit below this line--------------------------
$auto_respond_subject = 'TEAM:BARIATRICS Informational Packet Request';
$auto_respond_body = "Thank you for requesting your free TEAM:BARIATRICS Informational Packet. \n
You should recieve your packet within 5-10 business days.\n If you would like additional information, call 574.537.TEAM or visit us online at www.butneveragain.org.";
mail($email_field, $auto_respond_subject, $auto_respond_body,$header);
$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: Online Request");

echo '<META HTTP-EQUIV=Refresh CONTENT="0; URL='.$url.'">';


?>

Link to comment
Share on other sites

Here's all of the code... (DarkWater is taking a look at it too) He said he's not getting any errors but when I fill out the form on the website I do. This is getting really weird...

 

<?php
//--------------------------Set these paramaters--------------------------
// Subject of email sent to you.
$subject = 'TEAM:BARIATRICS Informational Packet Request';
// Your email address. This is where the form information will be sent.
$emailadd = 'aubreyburkhart@comcast.net';
// Where to redirect after form is processed.
$url = 'http://www.butneveragain.org/info/thankyou.html';
// 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.
$req = '0';
// Email address put into Email Field
$email_field = $_POST["Email"]; 
//Here is where I set the headers, you can add more if ever necessary 
$headers = "From: Team:Bariatrics <ghsfiles@box394.bluehost.com>";

// --------------------------Do not edit below this line--------------------------
$auto_respond_subject = 'TEAM:BARIATRICS Informational Packet Request';
$auto_respond_body = "Thank you for requesting your free TEAM:BARIATRICS Informational Packet. \n
You should recieve your packet within 5-10 business days.\n If you would like additional information, call 574.537.TEAM or visit us online at www.butneveragain.org.";
mail($email_field, $auto_respond_subject, $auto_respond_body, $headers);
$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: Online Request");
echo '<META HTTP-EQUIV=Refresh CONTENT="0; URL='.$url.'">';
?>

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.