Click here to Skip to main content
15,920,111 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am a newbie when it comes to php and I am trying to use it for a simple newsletter signup form. the html form has an input field for users to enter their emails and submit

The form works well and it sends a blank email to the address specified in the php code. I would like the email body to have something like "I would like to signup for your newsletter instead of being blank.

The php code is;

XML
<?php

$emailmanager = 'test@example.com';

error_reporting(0);

$email = trim($_POST['email']);
$Ok = ereg("^([a-zA-Z0-9_\.-]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$", $email);
if ($Ok) {
    mail($emailmanager,'New NewsFlash Subscriber','','From: '.$email);

    if(!ereg("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$",$UNameFrm))
    {
    ?>
<script language = 'javascript'>
    alert('Thank you, your address was added to our Mailing List');
    history.go(-1);
    </script>
<?
    exit();
    }
}

else {
    if(!ereg("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$",$UNameFrm))
    {
    ?>
<script language = 'javascript'>
    alert('Sorry, please provide a valid Email address.');
    history.go(-1);
    </script>
<?
    exit();
    }
}
?>


Your help will be highly appreciated
Posted
Comments
Mohibur Rashid 25-Jul-13 4:48am    
then you should write something in the body parameter part instead of ''

1 solution

Here is the code

if ($Ok) {
    
    $body = 'I would like to signup for your newsletter';

    mail($emailmanager,'New NewsFlash Subscriber', $body, 'From: '.$email);


Note: $body added into mail function.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900