Please Help Me With This Email Form

Discussion in 'Programming' started by skypeace, Aug 13, 2009.

  1. #1
    Hi,

    Please go to www.rockstahmedia.com and click the contact tab.

    There is a form over there, how do i make it like a working contact form?

    Please can someone help me out.

    Thanks!
     
    skypeace, Aug 13, 2009 IP
  2. kblessinggr

    kblessinggr Peon

    Messages:
    539
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Well for starters action="#" isn't going to go anywhere. You need to send the content somewhere, preferably a php page or other script that can take the form details and either email it to you or save it. It's generally not advised to use the mailto:youremail.com method as the action.

    By the way when you click on the link at the bottom of the site that says its valid xhtml... its not, has over 43 errors.
     
    kblessinggr, Aug 13, 2009 IP
  3. skypeace

    skypeace Well-Known Member

    Messages:
    2,348
    Likes Received:
    125
    Best Answers:
    0
    Trophy Points:
    130
    #3
    Thanks!

    I know that '#' is not going to work.

    Can you tell me what to do so that I can do something with PHP and mail it.
     
    skypeace, Aug 13, 2009 IP
  4. kblessinggr

    kblessinggr Peon

    Messages:
    539
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    0
    #4
    In a nutshell, and keep in mind this is completely minimal and unfurnished and does not take into consideration spam and form abuse, but would work, you can try this:

    Your form:
    
    <form action="send.php" method="post">
    <img src="images/leave-a.gif" alt="Leave a message" />
    <ul>
    <li><input type="text" class="text-name" name="contact_name"/></li>
    <li><input type="text" class="text-email" name="contact_email"/></li>
    <li><textarea class="message" rows="2" cols="25" name="the_message"></textarea></li>
    <li><input type="image" src="images/send.gif" class="submit" alt="submit" /></li></ul></form>
    
    Code (markup):
    send.php
    
    <?
    $name = $_POST['contact_name'];
    $email = $_POST['contact_email'];
    $message = $_POST['the_message'];
    
    mail('youremail@domain.com', '[SiteMail From '.$name.']', $message);
    
    //sends user back to site, could be modified to send them to a thank you page
    header('location:index.php');
    ?>
    
    PHP:
    To go a step further would look into something like reCaptcha to prevent automated spams to your contact box, and using PHPMailer to send mail via SMTP if you need the message to come in a cleaner format (though the latter isn't as important if you're the only one getting the emails and your server supports sendmail)
     
    kblessinggr, Aug 13, 2009 IP
    farrhad likes this.
  5. skypeace

    skypeace Well-Known Member

    Messages:
    2,348
    Likes Received:
    125
    Best Answers:
    0
    Trophy Points:
    130
    #5
    Thanks dude!

    I'll work on that.

    Rep added.
     
    skypeace, Aug 13, 2009 IP