How can I receive an email when the user hits "submit" button?

Discussion in 'HTML & Website Design' started by jimsmith, Mar 20, 2007.

  1. #1
    In order to collect addys for a newsletter:
    On my new website I have a text box, and a button. (among other things ;) ).
    When the person types their email address in the box, and hits the button, I want their email address sent to my email box.

    How do I attach that code, to that button-press?
    Just point me in the right direction, I'll figure it out from there. Thanks.
     
    jimsmith, Mar 20, 2007 IP
  2. bacanze

    bacanze Peon

    Messages:
    2,419
    Likes Received:
    127
    Best Answers:
    0
    Trophy Points:
    0
    #2
    bacanze, Mar 20, 2007 IP
  3. Cal813

    Cal813 Active Member

    Messages:
    856
    Likes Received:
    21
    Best Answers:
    0
    Trophy Points:
    85
    #3
    Yeah I was about to say, you need a form and need to properly set it up ;) Good luck.
     
    Cal813, Mar 20, 2007 IP
  4. jimsmith

    jimsmith Peon

    Messages:
    629
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Thanks for the link. It's real close to what I need, but not exactly. To clarify, I already have the form. I just need the code for the submit button to send the text to my email box.
    This is the only code that link gave for the submit button.
    again thanks guys
     
    jimsmith, Mar 20, 2007 IP
  5. jimsmith

    jimsmith Peon

    Messages:
    629
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    0
    #5
    [​IMG]
    the site you offered has a perfect example of what I'm trying to do.
    How they get that thing to work?
     
    jimsmith, Mar 20, 2007 IP
  6. bscdesign.com

    bscdesign.com Active Member

    Messages:
    681
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    58
    #6
    It has nothing to do with the submit button. You need a script to take the info and send it to your email. Then in the form tag you have the action set to the location of the script.

    Example:
    <form method="post" action="sendemail.php">
    Code (markup):
     
    bscdesign.com, Mar 21, 2007 IP
  7. joesgraphics

    joesgraphics Peon

    Messages:
    206
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #7
    hi jimsmith what code do you want to use if its php and you still need help just ask and ill help you. :)
     
    joesgraphics, Mar 22, 2007 IP
  8. beautyinmd

    beautyinmd Peon

    Messages:
    1,213
    Likes Received:
    121
    Best Answers:
    0
    Trophy Points:
    0
    #8
    Okay so you just basically need the php code. Here is one I used for my site- You just have to change it for yours. Open up notepad- save it as the name of the file- instead of text save as all file- just save it as send.php or whatever you choose .php- You will also need to tell the form you are using to use the php file- as bscdesign.com showed and a thank you page.

    <?PHP
    #This secton sends you a notification email when
    # the form is used

    // Your email address (for copies to be sent to you)
    $emailto=" PUT YOUR EMAIL HERE";

    // Your email subject text
    $esubject= " PUT SUBJECT HERE";

    // The email text for copies sent to you
    $email text="
    You have a message from a visitor and it is followed:

    Name:".$name."
    Email address:".$email."
    Country:".$country."
    ";
    #Send the email to you
    @mail("$emailto", $esubject, $emailtext,"From: $email")

    ##This section sends to the recipients
    // Target page after successful submission
    $thankyoupage="thanks.html";
    #After submission, the target URL
    header ("Location: $thankyoupage");
    exit;
    ?>
     
    beautyinmd, Mar 23, 2007 IP
  9. jimsmith

    jimsmith Peon

    Messages:
    629
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    0
    #9
    how do i have the .$name. and email and country fields filled out in the email it sends to me?
    I have 3 text boxes, named "name" "email" "text"
    So far the emails have been empty except for the text from the php file
     
    jimsmith, Mar 25, 2007 IP
  10. jimsmith

    jimsmith Peon

    Messages:
    629
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    0
    #10
    can someone please help me pass these variables ?
    I feel I'm so close!
     
    jimsmith, Mar 26, 2007 IP
  11. boyponga

    boyponga Banned

    Messages:
    1,013
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    0
    #11
    You must have a background on php in order to do this (or any languages that supports email sending). In php, here is the code:

    <?php
       if (isset($_REQUEST['email']))
    //if "email" is filled out, send email
      {
        //send email
    	$name=$_REQUEST['name'];
      $email = $_REQUEST['email'] ; 
      $subject = $_REQUEST['subject'] ;
      $message = $_REQUEST['message'] ;
      $to = "jpacelajado619@gmail.com";
    //Check first whether the strings meet the format of typing the email 
    if (!ereg('^[-!#$%&\'*+\\./0-9=?A-Z^_`a-z{|}~]+'.
                  '@'.
                  '[-!#$%&\'*+\\/0-9=?A-Z^_`a-z{|}~]+\.'.
                  '[-!#$%&\'*+\\./0-9=?A-Z^_`a-z{|}~]+$', $email))
    {
                  echo "Sorry! Invalid e-mail address! return to <a href="."contactus.html". ">this page</a>";
                  } 
    			  else 
    			  if($name == NULL || $email == NULL )
    			  {
    			  echo "Please specify name and email, go back to <a href="."contactus.html".">this page</a>";
    			  }			  
    			  else {
    //this is the correct pattern on sending the email
    			  mail($to, "Subject: $subject", $name."".$message, "From: $email" );
    			    echo "Thank you for using our mail form"; 
    				}
      //$to = "$email, $from";
      }
    else
    //if "email" is not filled out, display the form
      {
      echo "<b>For quick inquiries, Please enter the following information: </b>";
      echo "<br /><form method='post' action='contactus.html'>
     <div><div>Name:</div><div><input name='name' type='text' /></div><div>Email:</div><div><input name='email' type='text' /></div>
     <div>Subject:</div><div><input name='subject' type='text' /></div>
    <div>Message:</div>
    <div><textarea name='message' rows='15' cols='40'>
      </textarea></div>
    <div>  <input type='submit' /></div></div>
      </form>";
      }
      
    ?>
    PHP:
     
    boyponga, Mar 27, 2007 IP
  12. jimsmith

    jimsmith Peon

    Messages:
    629
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    0
    #12
    problem solved,
    this is what helped me to pass the variables, thanks boyponga
    thank you everyone
     
    jimsmith, Mar 27, 2007 IP
  13. habibicollection

    habibicollection Peon

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #13
    Dear All Members,
    Iam looking for a form for an email subscribe as to collect the database of my visitors who subscribe all the email should come to my email address.Any help.
    Habibi Collection
     
    habibicollection, Jul 26, 2008 IP
  14. garrettheel

    garrettheel Peon

    Messages:
    341
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    0
    #14
    I'm not sure there's a "form" that would do all of that for you as I think you're asking for the data to be added to your database. I do php coding and could code it for a small fee if you like.
     
    garrettheel, Jul 26, 2008 IP
  15. Dr.data

    Dr.data Active Member

    Messages:
    31
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    61
    #15
    The example below sends a text message to a specified e-mail address:

     
    Dr.data, Jul 31, 2008 IP