Stupid question?

Discussion in 'HTML & Website Design' started by BannanoPeel, Nov 13, 2009.

  1. #1
    So I made a form for my site it looks good and everything, except for one problem. How do I make it so when users hit submit the form email gets emailed to me? Right now when I hit submit it doesn't do anything except refresh.
     
    BannanoPeel, Nov 13, 2009 IP
  2. SCLocal

    SCLocal Notable Member

    Messages:
    1,270
    Likes Received:
    58
    Best Answers:
    0
    Trophy Points:
    235
    #2
    Your 'form method' isn't correct. See the following code:
    <CENTER>
    <FORM METHOD=POST ACTION="mailto:someone@$nailmail.com" ENCTYPE="text/plain">
    <INPUT TYPE="text" NAME="username"> : name <BR  />
    <INPUT TYPE="text" NAME="email"> : email <BR />
    comments <BR />
    <TEXTAREA NAME="COMMENTS" ROWS="10" WRAP="hard">
    </TEXTAREA>
    <INPUT NAME="redirect" TYPE="hidden" VALUE="index.html">
    <INPUT NAME="NEXT_URL" TYPE="hidden" VALUE="index.html">
    <BR />
    <INPUT TYPE="submit" VALUE="Send">
    <INPUT TYPE="reset" VALUE="Clear">
    </FORM>
    </CENTER>
    <!-- END OF FORM -->
    Code (markup):
     
    SCLocal, Nov 13, 2009 IP
  3. white10

    white10 Peon

    Messages:
    38
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Dont use Capital letters in your html tags, its invalid mark up
     
    white10, Nov 13, 2009 IP
  4. drhowarddrfine

    drhowarddrfine Peon

    Messages:
    5,428
    Likes Received:
    95
    Best Answers:
    7
    Trophy Points:
    0
    #4
    Capital letters are NOT invalid HTML markup.
     
    drhowarddrfine, Nov 13, 2009 IP
  5. azza87

    azza87 Peon

    Messages:
    6
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Search google for a free php contact form script. It's easy to set up, theres a few setup tutorials out there.
     
    azza87, Nov 13, 2009 IP
  6. wd_2k6

    wd_2k6 Peon

    Messages:
    1,740
    Likes Received:
    54
    Best Answers:
    0
    Trophy Points:
    0
    #6
    It's not invalid but annoying!

    Rather than using mailto, which forces the user to open their e-mail client and more (also you will probably get a whole load of spam) you should just use the PHP mail function to send it across.
     
    wd_2k6, Nov 13, 2009 IP
  7. BannanoPeel

    BannanoPeel Member

    Messages:
    94
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    41
    #7
    Is their any other way for me to get the information? The only reason being that I am using an HTML form. I have looked into something like this:
    <form name="input" action="html_form_submit.asp" method="get">
    HTML:
    But when I look at the file it dosen't have anything in it.
     
    BannanoPeel, Nov 14, 2009 IP
  8. adviceforall

    adviceforall Banned

    Messages:
    1,608
    Likes Received:
    24
    Best Answers:
    0
    Trophy Points:
    0
    #8
    Pm me Ill sort out out
     
    adviceforall, Nov 14, 2009 IP
  9. wd_2k6

    wd_2k6 Peon

    Messages:
    1,740
    Likes Received:
    54
    Best Answers:
    0
    Trophy Points:
    0
    #9
    Well Basically you need to use a short script in order to automatically send the data from a form to your e-mail. The most commonly used way to do this is via PHP, for example this is how I would do it:

    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Untitled Document</title>
    </head>
    
    <body>
    <?php
    if($_POST['submit']){
    	//Then the Form has Been Submitted
    	
    	//Assign the Variables
    	$input1 = $_POST['input1'];
    	$input2 = $_POST['input2'];
    	
    	//Now let's send the mail
    	
    	//E-mail to Send the Comments to
    	$to = "my-mail@example.co.uk";
    	
    	//Subject of the E-mail
    	$subject = "Testing Feedback Commments";
    	
    	//Contents of the E-mail
    	$message = "My Message Goes here \n
    				The user entered $input1 into the input1 box
    				They also entered $input2 into the input2 box";
    	
    	//E-mail Headers
    	$headers = "From: webmaster@mysite.com";
    	
    	//Here We Actually Send the Mail
    	$mail_sent = mail( $to, $subject, $message, $headers );
    	
    	//Confirm Success
    	echo $mail_sent ? "Mail sent" : "Mail failed";
    	
    }
    ?>
    <form id="feedback-form" action="" method="post">
    	<label for="input1">Input Example 1:</label>
    		<input type="text" name="input1" id="input1" />
            
    	<label for="input2">Input Example 2:</label>
    		<input type="text" name="input2" id="input2" />
            
    	<input type="submit" name="submit" value="Send Comments" />
    <!-- #feedback-form --></form>
    </body>
    </html>
    
    PHP:
    You already say you have the form setup, so just change this so the opening form tag has in it:

    <form action="" method="post">

    Then you just change the variables in the script, where it says "Assign the Variables", you change the input1 part in $_POST['input1'], to the name of one of your fields, and repeat this for all of your fields.
    Then change the e-mail and test it out!

    Just post you whole code if you are still having problems.
     
    wd_2k6, Nov 15, 2009 IP
  10. ODOnline

    ODOnline Peon

    Messages:
    230
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #10
    Use wd_2k6's Code

    Also, if you host that code in an external file (let's say "sendmail.php") then you should use

    <form action="sendmail.php" method="post">
     
    ODOnline, Nov 15, 2009 IP
  11. BannanoPeel

    BannanoPeel Member

    Messages:
    94
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    41
    #11
    Thanks for all the help guys, I was able to get it working by using cgiemail and it works now. The only problem is that I am trying to put this form in side of a forum and the form generator I used made a separate form.html and form.css file. Is their anyway I can put the CSS file into the HTML file without to much trouble?
     
    BannanoPeel, Nov 15, 2009 IP
  12. white10

    white10 Peon

    Messages:
    38
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #12
    If you run code with capital letters(tags) in Markup Validation Service your code will not validate

    element "CENTER" undefined. Did you mean "center"?
     
    white10, Nov 18, 2009 IP
  13. FireFightDesigns

    FireFightDesigns Peon

    Messages:
    39
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #13
    this is interesting
     
    FireFightDesigns, Nov 18, 2009 IP