Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 12-07-2010, 03:01 PM   PM User | #1
cb2004
New Coder

 
Join Date: Mar 2007
Posts: 64
Thanks: 0
Thanked 0 Times in 0 Posts
cb2004 is an unknown quantity at this point
Help with email signup (single textbox emailed to myself)

On each page of my website I have a form, I want this to be the users email sent to my email. So far I have this but no joy on the send part. What am I doing wrong.

Code:
<form action="" method="post">
<?php
	$sent = $_POST['newsletter'];
	if (!$sent) {
		echo '<input name="newsletter-email" type="text" id="wo" />
		<input type="image" name="newsletter" id="wogo" src="img/wogo.png" />';
	}
	elseif ($sent) {
		echo 'Sent';
	}
?>

</form>
cb2004 is offline   Reply With Quote
Old 12-07-2010, 03:05 PM   PM User | #2
muneeba9071
Regular Coder

 
Join Date: Dec 2008
Posts: 120
Thanks: 15
Thanked 2 Times in 2 Posts
muneeba9071 is an unknown quantity at this point
Try this,
PHP Code:
<form action="" method="post">
<?php
    $sent 
$_POST['newsletter'];
        
mail("you@yoursite.com","Subject","{$sent}");

    if (!
$sent) {
        echo 
'<input name="newsletter-email" type="text" id="wo" />
        <input type="image" name="newsletter" id="wogo" src="img/wogo.png" />'
;
    }
    elseif (
$sent) {
        echo 
'Sent';
    }
?>

</form>
Change the e-mail address in the code and that's it.
muneeba9071 is offline   Reply With Quote
Old 12-07-2010, 03:17 PM   PM User | #3
cb2004
New Coder

 
Join Date: Mar 2007
Posts: 64
Thanks: 0
Thanked 0 Times in 0 Posts
cb2004 is an unknown quantity at this point
I receive a blank email but the 'Sent' text does not appear.
cb2004 is offline   Reply With Quote
Old 12-07-2010, 03:19 PM   PM User | #4
muneeba9071
Regular Coder

 
Join Date: Dec 2008
Posts: 120
Thanks: 15
Thanked 2 Times in 2 Posts
muneeba9071 is an unknown quantity at this point
Try this,

PHP Code:
<form action="" method="post">
<?php
    $sent 
$_POST['newsletter'];
    if(
$_POST) {
         
mail("you@yoursite.com","Subject","{$sent}");
    }

    if (!
$sent) {
        echo 
'<input name="newsletter-email" type="text" id="wo" />
        <input type="image" name="newsletter" id="wogo" src="img/wogo.png" />'
;
    }
    elseif (
$sent) {
        echo 
'Sent';
    }
?>

</form>
muneeba9071 is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 05:43 AM.


Advertisement
Log in to turn off these ads.