Jump to content

Two emails on php form sumbission


mikal

Recommended Posts

???

 

My form works, but I get two emails: 

In the From part when i test it I get the person email address who sent it.

AND

I get one from Apache

 

Can anyone tell me how to stop this.  Not savvy enough to figure it out with tutorials I seen.

 

My thank you page which submits the results look like this code:

 

<?php

 

/*$ip = $_POST['ip'];*/

$httpref = $_POST['httpref'];

$httpagent = $_POST['httpagent'];

$visitor = $_POST['visitor'];

$visitormail = $_POST['visitormail'];

$notes = $_POST['notes'];

$attn = $_POST['attn'];

 

if(!$visitormail == "" && (!strstr($visitormail,"@") || !strstr($visitormail,".")))

{

echo "<h2>Use Back - Enter valid e-mail</h2>\n";

$badinput = "<h2>Feedback was NOT submitted</h2>\n";

echo $badinput;

}

 

if (eregi('http:', $notes)) {

die ("Do NOT try that! ! ");

}

 

if(empty($visitor) || empty($visitormail) || empty($notes )) {

echo "<h2>Use Back - fill in all fields</h2>\n";

}

 

$todayis = date("l, F j, Y, g:i a") ;

 

$attn = $attn ;

$subject = "Case Referral from HornLaw-referral.com";

 

$notes = stripcslashes($notes);

 

$message = " $todayis [EST] \n

Attention: $attn \n

Message: $notes \n

From: $visitor ($visitormail)\n

Additional Info : IP = $ip \n

Browser Info: $httpagent \n

Referral : $httpref \n

";

 

$from = "From: $visitormail\r\n";

 

 

mail("MyAddress@ThisDomain.com", $subject, $message, $from);

 

?>

 

<p align="left">

<span class="price"><span class="price">Date</span>:</span> <?php echo $todayis ?>

<br />

<span class="style22"><span class="style23">Thank You</span>:</span> <?php echo $visitor ?> <br />

( <?php echo $visitormail ?> )

<br />

<span class="price"><span class="style23">Message</span>:</span><br />

<?php $notesout = str_replace("\r", "<br/>", $notes);

echo $notesout; ?>

<br />

<?php echo $ip ?>

 

Any help out there.  An advanced Thank you of any help.

 

m

Link to comment
Share on other sites

it's because you're not using an if() conditional to only send the e-mail if the form was sent.  it will send an e-mail every time the page is accessed because that's exactly what it's written to do:

 

if (isset($_POST['submit_button_name']))
{

  // the header code here

}

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.