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 6 of 6

Thread: Contact Form

  1. #1
    New to the CF scene
    Join Date
    Dec 2011
    Location
    Aberdeen, Scotland
    Posts
    5
    Thanks
    6
    Thanked 0 Times in 0 Posts

    Contact Form

    Hi there,
    I am building a website at the moment using Dreamweaver and need to do a form on the contact page. Can anyone help me produce a working form with Php code and a thankyou for contacting us page ?? The form fields are Name:, Email:, Tel:, Message: and the Submit button.
    Any help would be greatly appreciated, as I am pulling out the hair I have left grrrrrrrrr!!

    This post has been edited by Rayb: Today, 01:08 AM

  • #2
    Regular Coder LearningCoder's Avatar
    Join Date
    Jan 2011
    Location
    The Pleiades
    Posts
    924
    Thanks
    76
    Thanked 29 Times in 29 Posts
    Code:
    <form name="yourForm" method="POST" action="some_php_file.php">
         <fieldset>
         <legend>The name of your form here</legend>
         <p><label for="name">Name:</label><input type="text" name="usersname" /></p>
         <p><label for="email">Email:</label><input type="text" name="email" /></p>
         <p><label for="tel">Telephone:</label><input type="text" name="tel" /></p>
         <p><label for="message">Message:</label><textarea name="message" rows="5" cols="30"></textarea></p>
         <p><label for="submit">Submit</label><input type="submit" name="submit" value="Proceed" /></p>
        </fieldset>
    </form>

  • Users who have thanked LearningCoder for this post:

    raybrown (07-19-2012)

  • #3
    New to the CF scene
    Join Date
    Jul 2012
    Location
    India
    Posts
    2
    Thanks
    0
    Thanked 1 Time in 1 Post
    working form with php? then you should post this in php anyways here is a simple form

    Code:
    <form name="contactus" action="submit.php" method="post">
    Name: <input type="text" name="nm" /><br />
    Email: <input type="text" name="mail" /><br />
    Tel: <input type="text" name="tel" /><br />
    Message: <textarea name="msg" rows="5" cols="25"></textarea><br />
    <input type="submit" />
    
    </form>
    submit.php
    Code:
    <?php
    $nm = htmlentities($_POST['nm'],ENT_QUOTES);
    $mail = htmlentities($_POST['mail'],ENT_QUOTES);
    $tel = htmlentities($_POST['tel'],ENT_QUOTES);
    $msg = htmlentities($_POST['msg'],ENT_QUOTES);
    
    $cnn = mysql_connect("localhost", "your db user name", "your db password");
    mysql_select_db("your database");
    
    $sql = "INSERT INTO feedback (name, email, telephone, message)VALUES ('$nm', '$mail', '$tel', '$msg')";
    $result = mysql_query($sql);
    echo "sucess";
    ?>
    don't forget to setup your database

  • Users who have thanked anki for this post:

    raybrown (07-19-2012)

  • #4
    Regular Coder LearningCoder's Avatar
    Join Date
    Jan 2011
    Location
    The Pleiades
    Posts
    924
    Thanks
    76
    Thanked 29 Times in 29 Posts
    raybrown please note that with the php code provided, you will have to validate the email address (and the other fields) to make sure it is valid before inserting into the database, otherwise I could type cf@cf@cf@lc.com.co.uk.org and it would still insert that into the database even though it clearly isn't a valid email address. To validate an email address, try using this in submit.php BEFORE inserting the data into the database:

    PHP Code:
    if(!filter_var($emailFILTER_VALIDATE_EMAIL)){
       
    //email is not valid, so maybe you could redirect the user back 
       //to your contact us page and ask them to re-enter the email address?
    }
    else{
       
    //anything else, this means the email is valid so you can insert 
       //into the database in the else statement or validate the other fields

    Kind regards,

    LC.
    Last edited by LearningCoder; 07-17-2012 at 09:22 AM. Reason: re-worded and formatted code

  • Users who have thanked LearningCoder for this post:

    raybrown (07-19-2012)

  • #5
    Regular Coder
    Join Date
    Aug 2005
    Location
    MS
    Posts
    841
    Thanks
    11
    Thanked 79 Times in 77 Posts
    Setting Up the SMTP Service: http://www.code-crafters.com/ability...rial_smtp.html

    PHP: Sending Email Tutorial (Text/HTML/Attachments): http://www.webcheatsheet.com/php/sen...attachment.php

    Use any of the below sites to make the workable form you need (Just follow the instructions for making it and uploading file(s)):

    Contact Form Generator: http://www.tele-pro.co.uk/scripts/contact_form/
    WYSIWYG Form Maker (Easiest to Use): http://www.jotform.com/?gclid=CNKhqe...FRQhnAod6laUqA
    http://www.thesitewizard.com/wizards/feedbackform.shtml
    http://www.form2email.net/
    http://www.phpform.org/

    Free Forms: http://www.jotform.com/form-templates/

    http://www.thepcmanwebsite.com/form_mail.shtml
    http://emailmeform.com/
    http://www.freecontactform.com/
    http://www.reconn.us/content/view/12/34/ (Download - Contact Us Script)
    http://formsmarts.com/

    http://apptools.com/phptools/forms/forms1.php
    Form Service: http://www.mycontactform.com/
    Online Free Tool, PHP Contact Form Code Generator: http://www.htmlbasix.com/contactform.shtml
    PHP Mailer Script Step by Step: http://www.htmlgoodies.com/beyond/ph...le.php/3855686
    PHP Sending E-mails: http://www.w3schools.com/PHP/php_mail.asp

    How to Make a Slick Ajax Contact Form with jQuery and PHP: http://www.elated.com/articles/slick...rm-jquery-php/
    Ajax - Creating an HTML Form: http://www.tizag.com/ajaxTutorial/ajaxform.php

    Freebie: Good looking Fluid Contact Form: http://www.flashuser.net/flash-compo...tact-form.html

    Put an online contact form on your site in about 8 minutes (Requires an account): http://response-o-matic.com/

    Form2Email.net (free - Designed to keep away spam. Your e-mail address is hidden in the script. Can be used to send almost any form, and if required, keeps a log of all e-mails. Supports required fields, SMTP, multiple e-mails, auto responder and file upload.): http://www.form2email.net/

    How to submit a form to multiple email addresses: http://webdesign.about.com/b/2008/01...-addresses.htm

    How to Code a Sign Up Form with Email Confirmation: http://net.tutsplus.com/tutorials/ph...-confirmation/
    ☠ ☠RON☠ ☠

  • The Following 2 Users Say Thank You to Major Payne For This Useful Post:

    raybrown (07-19-2012), Will Bontrager (07-18-2012)

  • #6
    Senior Coder
    Join Date
    Feb 2006
    Location
    USA
    Posts
    1,013
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Learn CSS. | SSI | PHP includes | X/HTML Validator | CSS validator | Dynamic Site Solutions
    Java != JavaScript && JScript != JavaScript
    Design/program for Firefox (and/or Opera), apply fixes for IE, not the other way around.


  •  

    Posting Permissions

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