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 8 of 8
  1. #1
    New Coder
    Join Date
    Nov 2011
    Posts
    38
    Thanks
    1
    Thanked 0 Times in 0 Posts

    new to HTML forms - help

    I am new to creating a HTML form where people fill out their Name, Email, and Message and that info gets emailed to me. Any help would be great. thanks.

  • #2
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,603
    Thanks
    0
    Thanked 645 Times in 635 Posts
    You need both the form in the HTML and a server side form2mail script to be able to do that.
    Stephen
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.

  • #3
    New Coder
    Join Date
    Nov 2011
    Posts
    38
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by felgall View Post
    You need both the form in the HTML and a server side form2mail script to be able to do that.
    i have a sendEmail.php script that I used with a HTML service in flex. I believe the script will work here to, right?

    PHP Code:
    <?php
        $senderName 
    $_POST['senderName'];
        
    $senderEmail =  $_POST['senderEmail'];
        
    $senderComments $_POST['senderComments'];
        
    $sendType $_POST['sendType'];
        
    $sendToEmail "jason@benedictumdesigns.com";
        
        
    $recipient "$sendToEmail";
        
    $subject "Web Contact: " $sendType " form";
        

        
    $message "
        From: " 
    $senderName ." \n
        Email Address: " 
    $senderEmail "\n
        
        Message: $senderComments\n
        Interests: $senderInterests"
    ;
        
        
    $headers "From: " $senderEmail;
          
    $message stripslashes($message);
         
        
    mail($recipient$subject$message$headers)
    ?>

  • #4
    New Coder
    Join Date
    May 2012
    Posts
    34
    Thanks
    0
    Thanked 2 Times in 2 Posts
    Hi akuria, You have given perfect and very helpful information about Email.php script. this script very helpful for me because I am working as PHP developer last 6 month. So thanks for sharing this fantastic information.

  • #5
    Regular Coder
    Join Date
    Jun 2012
    Location
    Near Chicago, USA
    Posts
    123
    Thanks
    7
    Thanked 19 Times in 19 Posts
    I see you have a script to process the form submission. That's good.

    But you still need the form.

    This is an excellent site to learn how to code forms: http://www.w3schools.com/html/html_forms.asp

    And this, if you just need a simple form quickly, can help you generate form code: http://www.willmaster.com/create-form/

    Use the PHP script as clues for naming the form fields. Form field name="senderName" for the name of the person filling in the form, for example.

    I wish you the best. Coding can be a pleasure.

    Will

  • #6
    New Coder
    Join Date
    Nov 2011
    Posts
    38
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Will Bontrager View Post
    I see you have a script to process the form submission. That's good.

    But you still need the form.

    This is an excellent site to learn how to code forms: http://www.w3schools.com/html/html_forms.asp

    And this, if you just need a simple form quickly, can help you generate form code: http://www.willmaster.com/create-form/

    Use the PHP script as clues for naming the form fields. Form field name="senderName" for the name of the person filling in the form, for example.

    I wish you the best. Coding can be a pleasure.

    Will
    Thanks for the info. I like the form generator you provided. also for for one site i want a more custom look.

  • #7
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,603
    Thanks
    0
    Thanked 645 Times in 635 Posts
    Quote Originally Posted by akuria View Post
    PHP Code:
    <?php
        $senderName 
    $_POST['senderName'];
        
    $senderEmail =  $_POST['senderEmail'];
        
    $senderComments $_POST['senderComments'];
        
    $sendType $_POST['sendType'];
    That part of the code is missing all the field validations and so someone would be able to run anything on your site simply by entering the appropriate entries into the form.

    Each field should be validated prior to moving it out of the $_POST array. If someone enters invalid garbage into any field you should redisplay the form and ask them to fix it.
    Stephen
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.

  • #8
    New Coder
    Join Date
    Nov 2011
    Posts
    38
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by felgall View Post
    That part of the code is missing all the field validations and so someone would be able to run anything on your site simply by entering the appropriate entries into the form.

    Each field should be validated prior to moving it out of the $_POST array. If someone enters invalid garbage into any field you should redisplay the form and ask them to fix it.
    sorry. still alittle new. how would i go about adding the validators. i have tried before and it never worked.


  •  

    Posting Permissions

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