Contact Form; how do I set up a contact form on webpage (html)

Discussion in 'HTML & Website Design' started by joeydee, Oct 29, 2009.

  1. #1
    joeydee, Oct 29, 2009 IP
  2. kind_of_the_cash

    kind_of_the_cash Active Member

    Messages:
    852
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    85
    #2
    That used ajax on light form

    If you use html you should have to use php / asp for form processing :)
     
    kind_of_the_cash, Oct 29, 2009 IP
  3. LeetPCUser

    LeetPCUser Peon

    Messages:
    711
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    0
    #3
    First you are going to have to implement JQuery. From the look of your source you have. You will then have to use a back-end language like PHP or ASP to take the text they entered in the fields and then email it to the specified email address(es) you want.

    If you want help on this don't hesitate to PM me.
     
    LeetPCUser, Oct 30, 2009 IP
  4. joeydee

    joeydee Guest

    Messages:
    47
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Hey Kind.

    Thanks for the tip, would you mind telling me what script I need to get? Preferably a free script. Thanks.
     
    joeydee, Oct 30, 2009 IP
  5. LeetPCUser

    LeetPCUser Peon

    Messages:
    711
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    0
    #5
    I can help you out with that. For your form you want this on the same page.

    
    <?php
     //checks to see if the name was sent
     if (!empty($_POST['name']))
     {
       //setup the address you want to email to
       $to = 'youremailaddress@email.com';
       //setup the subject of the email
       $subject = 'AKL Woodwork Contact Us';
    
       //add the users name to the message
       $message = 'Name: '.$_POST['name']."\n";
    
       //add the users website to the message if it exists
       if (!empty($_POST['website']))
       {
        $message .= 'Website: '.$_POST['website']."\n";
       }
    
       //add their message to the message
       $message .= 'Message: '.stripslashes($_POST['message']);
    
       //setup the header information
       $headers = 'From: '.$_POST['email']."\r\n".'Reply-To: '.$_POST['email'];
    
       //setup your message to allow 70 characters and then wrap them for the message
       $message = wordwrap($message, 70);
    
       //mail the message
       mail($to, $subject, $message, $headers);
    
      //print a message that it was mailed
      echo "<p>Thank you for your response.</p>";
     }
     //else if they have not submitted the form
     else
     {
    ?>
    
      <!-- Put all of your form stuff here -->
    
    <?php
     }
    ?>
    
    Code (markup):
     
    LeetPCUser, Oct 30, 2009 IP
  6. joeydee

    joeydee Guest

    Messages:
    47
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Hey mate.

    So here's what i understood, let me know if I've missed something... thanks again for the help (much appreciated)

    contact.html
    <FORM action="http://www.aklwoodwork.com/contact.php" method="post" class="ajax_form"> 
                            <FIELDSET><H3><SPAN><SPAN class="cufon cufon-canvas" style="width: 53px; height: 18px; "><CANVAS width="69" height="21" style="width: 69px; height: 21px; top: -2px; left: 0px; "></CANVAS><SPAN class="cufon-alt">Send </SPAN></SPAN><SPAN class="cufon cufon-canvas" style="width: 27px; height: 18px; "><CANVAS width="42" height="21" style="width: 42px; height: 21px; top: -2px; left: 0px; "></CANVAS><SPAN class="cufon-alt">us </SPAN></SPAN><SPAN class="cufon cufon-canvas" style="width: 18px; height: 18px; "><CANVAS width="33" height="21" style="width: 33px; height: 21px; top: -2px; left: 0px; "></CANVAS><SPAN class="cufon-alt">a </SPAN></SPAN><SPAN class="cufon cufon-canvas" style="width: 39px; height: 18px; "><CANVAS width="56" height="21" style="width: 56px; height: 21px; top: -2px; left: 0px; "></CANVAS><SPAN class="cufon-alt">mail</SPAN></SPAN></SPAN></H3> 
     
                            <P class=""><INPUT name="yourname" class="text_input empty" type="text" id="name" size="20" value=""><LABEL for="name">Your Name*</LABEL> 
                            </P> 
                            <P class=""><INPUT name="email" class="text_input email" type="text" id="email" size="20" value=""><LABEL for="email">E-Mail*</LABEL></P> 
                            <P><INPUT name="website" class="text_input" type="text" id="website" size="20" value=""><LABEL for="website">Website</LABEL></P> 
                            <LABEL for="message" class="blocklabel">Your Message*</LABEL> 
                            <P class=""><TEXTAREA name="message" class="text_area empty" cols="40" rows="7" id="message"></TEXTAREA></P> 
     
     
                            <P> 
                            <INPUT type="hidden" id="myemail" name="myemail" value="Hello@AKLwoodwork.com"> 
                            <INPUT type="hidden" id="myblogname" name="myblogname" value="Leviation"> 
     
                            <INPUT name="Send" type="submit" value="Send" class="button" id="send" size="16"></P> 
                                                    </FIELDSET> 
     
                           <?php
     //checks to see if the name was sent
     if (!empty($_POST['name']))
     {
       //setup the address you want to email to
       $to = 'Hello@AKLwoodwork.com';
       //setup the subject of the email
       $subject = 'AKL Woodwork Contact Us';
    
       //add the users name to the message
       $message = 'Name: '.$_POST['name']."\n";
    
       //add the users website to the message if it exists
       if (!empty($_POST['website']))
       {
        $message .= 'Website: '.$_POST['website']."\n";
       }
    
       //add their message to the message
       $message .= 'Message: '.stripslashes($_POST['message']);
    
       //setup the header information
       $headers = 'From: '.$_POST['email']."\r\n".'Reply-To: '.$_POST['email'];
    
       //setup your message to allow 70 characters and then wrap them for the message
       $message = wordwrap($message, 70);
    
       //mail the message
       mail($to, $subject, $message, $headers);
    
      //print a message that it was mailed
      echo "<p>Thank you for your response.</p>";
     }
     //else if they have not submitted the form
     else
     {
    ?>
    
      <!-- Put all of your form stuff here -->
    
    <?php
     }
    ?>
    
     </FORM> 
    
    Code (markup):
     
    joeydee, Oct 30, 2009 IP
  7. Om ji Kesharwani

    Om ji Kesharwani Peon

    Messages:
    211
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #7
    save your file with php extension in place of html.
    contact.php
    it should work...
     
    Om ji Kesharwani, Oct 30, 2009 IP
  8. LeetPCUser

    LeetPCUser Peon

    Messages:
    711
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    0
    #8
    Om is correct. Your file will have to be contact.php. Also, you will have to put your header and footer code in and your page info where I put the comment in. If you have any problems, feel free to post.
     
    LeetPCUser, Oct 30, 2009 IP
  9. joeydee

    joeydee Guest

    Messages:
    47
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #9
    Hey guys.

    Thanks agian for the help.

    I'm new to this and having some issues :(

    I know how to change the extension to .php - however here's where I run into a problem; screenshot of my FTP

    [​IMG]

    contact.html
    -This is where i would like to have the contact form work

    contact.php
    -This is an Ajax script I was testing out, im not sure what Iam doing really, and Im not sure if it's connected to my contact form on contact.html

    So if I were to replace the contact.html to contact.php it would over ride the script.

    Would it be too much to ask if you can help me with the changes and give me the files so that I can just upload them, cause I'm a little confused folks :(

    Thanks again.
     
    joeydee, Oct 30, 2009 IP
  10. LeetPCUser

    LeetPCUser Peon

    Messages:
    711
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    0
    #10
    Here is the structure.

    *all of your code before the text (header, white page, etc.)
    *the code i gave you for the post check and response with the email
    *in the else put the code to display the form
    *after the else print the footer information (closing divs, footer, etc.)

    Then point to the php file and it will be the html file only with the email processing. The email processing will all be handled on the same page.
     
    LeetPCUser, Oct 30, 2009 IP
  11. dj2oon

    dj2oon Active Member

    Messages:
    453
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    51
    #11
    you can made it in a dreamw and attach data base or go for wiget on wiget box dot com for it
     
    dj2oon, Nov 1, 2009 IP
  12. adolix

    adolix Peon

    Messages:
    787
    Likes Received:
    32
    Best Answers:
    0
    Trophy Points:
    0
    #12
    If you don't want to waste time with PHP and other programming issue, have a look at 123 Contact Form. You can make your contact form there, it's free, all you have to do is copy& paste the final HTML code on your contactus page.
     
    adolix, Nov 17, 2009 IP