Go Back   CodingForums.com > :: Client side development > HTML & CSS

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 07-17-2012, 08:10 AM   PM User | #1
raybrown
New to the CF scene

 
Join Date: Dec 2011
Location: Aberdeen, Scotland
Posts: 5
Thanks: 6
Thanked 0 Times in 0 Posts
raybrown is an unknown quantity at this point
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
raybrown is offline   Reply With Quote
Old 07-17-2012, 08:29 AM   PM User | #2
LearningCoder
Regular Coder

 
LearningCoder's Avatar
 
Join Date: Jan 2011
Location: The Pleiades
Posts: 849
Thanks: 67
Thanked 28 Times in 28 Posts
LearningCoder is an unknown quantity at this point
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>
LearningCoder is offline   Reply With Quote
Users who have thanked LearningCoder for this post:
raybrown (07-19-2012)
Old 07-17-2012, 08:48 AM   PM User | #3
anki
New to the CF scene

 
Join Date: Jul 2012
Location: India
Posts: 2
Thanks: 0
Thanked 1 Time in 1 Post
anki is an unknown quantity at this point
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
anki is offline   Reply With Quote
Users who have thanked anki for this post:
raybrown (07-19-2012)
Old 07-17-2012, 09:19 AM   PM User | #4
LearningCoder
Regular Coder

 
LearningCoder's Avatar
 
Join Date: Jan 2011
Location: The Pleiades
Posts: 849
Thanks: 67
Thanked 28 Times in 28 Posts
LearningCoder is an unknown quantity at this point
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
LearningCoder is offline   Reply With Quote
Users who have thanked LearningCoder for this post:
raybrown (07-19-2012)
Old 07-18-2012, 05:38 PM   PM User | #5
Major Payne
Regular Coder

 
Join Date: Aug 2005
Location: MS
Posts: 745
Thanks: 7
Thanked 65 Times in 63 Posts
Major Payne is an unknown quantity at this point
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☠ ☠
Major Payne is offline   Reply With Quote
The Following 2 Users Say Thank You to Major Payne For This Useful Post:
raybrown (07-19-2012), Will Bontrager (07-18-2012)
Old 07-20-2012, 11:13 PM   PM User | #6
Kravvitz
Senior Coder

 
Join Date: Feb 2006
Location: USA
Posts: 1,013
Thanks: 0
Thanked 0 Times in 0 Posts
Kravvitz is an unknown quantity at this point
As I said on DevShed, the "for" attribute of <label> elements should reference the ID of a form field. The form fields lack IDs.
__________________
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.
Kravvitz is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 05:16 PM.


Advertisement
Log in to turn off these ads.