www.webdeveloper.com
Results 1 to 4 of 4

Thread: Contact us page

  1. #1
    Join Date
    May 2010
    Posts
    41

    Contact us page

    Hello, I have a question. My question is: how do I make a form that when the viewer clicks "send", it puts it in an email which is then sent to me. I need this for my "contact us" page.


    CJ

  2. #2
    Join Date
    Jan 2011
    Location
    America
    Posts
    32
    The form would have to send the info via action attribute to a page which has a scripting language.

    PHP is a good example.

    Page 1: The HTML Page
    HTML Code:
    <form action="process.php" method="post">
    ...stuff
     <input type="submit" name="send_email" />
    </form>
    Page 2: The PHP Page
    PHP Code:
    <?php

    //Who is this email going to be sent to?
    $to 'youremail@gmail.com';
    //What is the email's subject
    $subject 'Thank You For Contacting Us';
    //What is the email's message
    $message 'This email is to inform you that we...';

    if(isset(
    $_POST['send_email']))    //User submitted form
    {

    if(
    mail($to,$subject,$message))
    {
    echo 
    '<p>We have received your message. Thank you for contacting us!</p>';
    }

    else
    {
    echo 
    '<p>There was a problem contacting us...try again later.</p>';
    }

    }

    else   
    //The user is visiting the page but the form wasn't submitted
    {
    echo 
    '<p>Please submit the form before viewing this page.</p>';
    }

    ?>

    This is just a basic script, it will send an email after the form is submitted and thats all.

    You can google the phrase "PHP Contact Page Tutorial" to get much better examples.

  3. #3
    Join Date
    May 2010
    Posts
    41

    Thanks a ton

    thanks SO much, this helped a lot. I now can have a decent "contact us" page.

    Thanks again,
    CJ

  4. #4
    Join Date
    Jan 2011
    Location
    America
    Posts
    32
    No problem. Glad I could help.

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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