Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New Coder
    Join Date
    Mar 2007
    Posts
    64
    Thanks
    0
    Thanked 0 Times in 0 Posts

    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>

  • #2
    Regular Coder
    Join Date
    Dec 2008
    Posts
    120
    Thanks
    15
    Thanked 2 Times in 2 Posts
    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.

  • #3
    New Coder
    Join Date
    Mar 2007
    Posts
    64
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I receive a blank email but the 'Sent' text does not appear.

  • #4
    Regular Coder
    Join Date
    Dec 2008
    Posts
    120
    Thanks
    15
    Thanked 2 Times in 2 Posts
    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>


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •