dcsimg
www.webdeveloper.com
Results 1 to 5 of 5

Thread: Input form & replies (for a novice)

  1. #1
    Join Date
    Apr 2010
    Location
    Whitley Bay, UK
    Posts
    27

    Input form & replies (for a novice)

    Hello

    I am new to all this xhtml and css business, but with a bit of practise, seem to be getting there.

    So far, I have not really bothered with input forms, although the initial xhtml bit doesn't look too difficult.

    I think I would now like a simple contact form for my website (under construction) with a small textarea, maybe a space for an e-mail and that's all.

    BUT !!! herte's the bit I don't understand

    How do I (as the webmaster) get the reply ?

    Is there a way to have the input simply e-mailed to me ?

    What is needed .. is it javascript or whatever ?

    Are there any simple downloadable scripts ?

    The site will be hosted by http://www.vidahost.com/ if that helps in any way

    I was going just to have a mailto link, but decided that mifght produce too much spam.

    Any help would be very much appreciated.

  2. #2
    Join Date
    Oct 2005
    Location
    Cambridgeshire, UK
    Posts
    191
    In order to actually send an enquiry form you need some kind of server side scripting language such as PHP.

    Check out this simple contact form as an example.

    Let me know if you need any more help.

  3. #3
    Join Date
    Jul 2009
    Posts
    184
    yes, PHP is the easiest way to do what you are thinking of, without using the mailto: tag.

    There is an excellent tutorial I recommend on how to build a basic html form that uses a PHP script to do what you wanted.

    This PHP file you create will get the information the user has entered into your html form, and email the information to the email address specified.

    http://www.w3schools.com/php/php_mail.asp

  4. #4
    Join Date
    Apr 2010
    Location
    Whitley Bay, UK
    Posts
    27
    Many thanks Biostall and Westweb

    I'll look into both options and see which one is the better, ior maybe they are actually pretty similar.

    Yes1 Westweb that W3Schools site is fantastic, I initially learnt all about html and css there; their 'try it yourself' option is very good indeed and certainly helps to clarify things.

    thanks again !

    Brian

    ps Do the automated email robots still pick up email addresses if done this way ?

  5. #5
    Join Date
    Mar 2010
    Posts
    37

    Smile

    Here is the simple PHP form:

    1: create a simple HTML file : contact.htm

    <form method="POST" action="form_handler.php">
    <input type="text" name="name" size="19"><br>
    <br>
    <input type="text" name="email" size="19"><br>
    <br>
    <textarea rows="9" name="message" cols="30"></textarea>
    <br>
    <br>
    <input type="submit" value="Send" name="submit">
    </form>

    2: PHP handler File: form_handler.php


    <?php
    if(isset($_POST['submit'])) {

    $to = "you@yourdomain.com";
    $subject = "New Contact";
    $name_field = $_POST['name'];
    $email_field = $_POST['email'];
    $message = $_POST['message'];

    $body = "From: $name_field\n E-Mail: $email_field\n Message:\n $message";

    echo "Thanking you for contacting me at: $to!";
    mail($to, $subject, $body);

    } else {

    echo "Oopss!! Some Error occured, Plz go back and send it again";

    }
    ?>

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles