Question:

Why does my newsletter subscription text box send me the contact email after I enter in the email addy twice?

by  |  earlier

0 LIKES UnLike

This is the code in my html doc:

<form action="newsletter.php" method="post" name="newsletter" type="text" size="23" id="newsletter" onsubmit="MM_validateForm('email','','Ri... document.MM_returnValue">

<input name="submit" type="text" id="submit" size="23" />

</form>

If I enter an email address and press enter the page refreshes and thats it. If I enter an email address on the refreshed page that the thank you page (newsletter.php) comes up and says thank you while an email is sent that time to the admin address.

This is the php:

/* Subject and Email Variables */

$emailSubject = 'Capitalsal Newsletter Subscription';

$webMaster = 'admin@capitalsal.com';

/* Gathering Data Variables */

$newsletterField = $_POST['newsletter'];

$body = <<<EOD

<br><hr><br>

Email Address: $newsletterField <br>

EOD;

$headers = "From: $email\r\n";

$headers .= "Content-type: text/html\r\n";

$success = mail($webMaster, $emailSubject, $body, $headers);

/* Results Rendered in Html */

$theResults = <<<EOD

 Tags:

   Report

1 ANSWERS


  1. Not th best possible &quot;design&quot;...

    index.html

    &lt;form action = &#039;newsletter.php&#039; method = &#039;post&#039; &gt;

    &lt;input type = &#039;text&#039; name = &#039;email&#039;&gt;

    &lt;input type = &#039;submit&#039; ... &gt;

    newsletter.php

    &lt;?php

    $email = $_POST [ &#039;email&#039; ];

    $to = &#039;webmaster...

    $header...

    $subject...

    $msg = &quot;Subscription from &quot; . $email . &quot; received.\r\n&quot;;

    mail ($to, $subject, $msg, $header);

    echo (&quot; Thank you ! &quot; );

    ?&gt;

    (remove added spaces)

    Check this first, THEN, if you want, use validations...

    No need to check the &quot;result&quot; of mail ( ): it does NOT tell you that the mail has been SENT, but just that the parameters are acceptable and the function exists...

Question Stats

Latest activity: earlier.
This question has 1 answers.

BECOME A GUIDE

Share your knowledge and help people by answering questions.