Creating Simple PHP Contact Form

When you need that user contact with you or send feedback to you via email then you have to need make a contact form. In this tutorial you will learn that how to create form with php script.

Overview

In this tutorial create 2 files 1. contact.php and 2. send_contact.php

Step
1. Create file contact.php.
2. Create file send_contact.php.

Step1:

Create file contact.php

View In Browser

CODE

………………………………………………………………………………………………………………………….

<table

width=”400″ border=”0″ align=”center” cellpadding=”3″

cellspacing=”1″>

<tr>

<td><strong>Contact Form </strong></td>

</tr>

</table>

<table

width=”400″ border=”0″ align=”center” cellpadding=”0″

cellspacing=”1″>

<tr>

<td><form method=”post”

action=”send_contact.php”>

<table width=”100%” border=”0″ cellspacing=”1″ cellpadding=”3″>

<tr>

<td width=”16%”>Subject</td>

<td width=”2%”>:</td>

<td width=”82%”><input name=”subject”

id=”subject” size=”50″></td>

</tr>

<tr>

<td>Detail</td>

<td>:</td>

<td><textarea name=”detail” cols=”50″ rows=”4″

id=”detail”></textarea></td>

</tr>

<tr>

<td>Name</td>

<td>:</td>

<td><input type=”text”

size=”50″></td>

</tr>

<tr>

<td>Email</td>

<td>:</td>

<td><input name=”customer_mail”

id=”customer_mail” size=”50″></td>

</tr>

<tr>

<td>&nbsp;</td>

<td>&nbsp;</td>

<td><input name=”Submit” value=”Submit”>

<input name=”Submit2″ value=”Reset”></td>

</tr>

</table>

</form>

</td>

</tr>

</table>

………………………………………………………………………………………………………………………….

Step2:

Create file send_contact.php

CODE

………………………………………………………………………………………………………………………….

<?php

// Contact subject

$subject

=”$subject”;

// Details

$message=”$detail”;

// Mail of sender

$mail_from=”$customer_mail”;

// From

$header=”from:

$name <$mail_from>”;

// Enter your email address

$to

=’someone@somewhere.com’;

$send_contact=mail($to,$subject,$message,$header);

// Check, if  message sent to your email

“We’ve recived your information”

if($send_contact){

echo “We’ve recived your contact information”;

}

else {

echo “ERROR”;

}

?>

………………………………………………………………………………………………………………………….

Apply and Comment …

Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • del.icio.us
  • StumbleUpon
  • Reddit
  • BlinkList
  • DZone
  • Facebook
  • Furl
  • Google Bookmarks
  • LinkedIn
  • Live-MSN
  • Mixx
  • MySpace
  • NewsVine
  • Propeller
  • Sphinn
  • Technorati
  • TwitThis
  • YahooBuzz

17 Responses to “Creating Simple PHP Contact Form”

  1. Creating Simple PHP Contact Form | Blog Links Says:

    [...] Creating Simple PHP Contact Form Sharevar fbShare = {url: 'http://bloglinks.ejazahmad.com/creating-simple-php-contact-form/',size: 'large',}Save submit_url = 'http://bloglinks.ejazahmad.com/creating-simple-php-contact-form/'; VN:F [1.9.1_1087]please wait…Rating: 0.0/10 (0 votes cast)VN:F [1.9.1_1087]Rating: 0 (from 0 votes) 3D, Design, Directory, Graphic Design, PHP, Photoshop, Templates, Vector [...]


  2. Kris Says:

    2 major issues with this:

    1. It won’t work. At no point in send_contact.php are the $_POST vars assigned to the vars that get used in the mail.

    2. It’s wide open to header injection. See http://phpsense.com/php/php-mail.html


  3. Cerah Says:

    Thank you so much for the tutorial. It was very helpful.

    I ended up using http://www.quickwebform.com

    It generates a code that I copy and paste my website. Do you know anything about them? It works great and it’s also free.


  4. anxiety disorders Says:

    Yea, this blog site is by significantly an individual of the ideal anywhere that I’ve observed. Kudos so significantly for assisting me out.


  5. Shelly Casper Says:

    Your blog is so informative ¡­ keep up the good work!!!!


  6. Edmond Goffer Says:

    I would like to say thank you for your posting about treating anxiety and panic attack!


  7. bzqdhbszdck Says:

    JN7ssA iuraglcpdrjs, [url=http://lpvtizywxnzs.com/]lpvtizywxnzs[/url], [link=http://ssbzwmxghvoa.com/]ssbzwmxghvoa[/link], http://jhepuyupetll.com/


  8. Tweets that mention Creating Simple PHP Contact Form | Designs Collage -- Topsy.com Says:

    [...] This post was mentioned on Twitter by mubashir, designscollage. designscollage said: http://www.designscollage.com/2010/06/creating-simple-php-contact-form/ [...]


  9. Dallas Cathy Says:

    hi,The Motif of your blog is very Suit to me, I hope more alternate with you this Subject.


  10. Club Penguin Says:

    hey, I added ur site to my RSS reader. the posts are awesome! :)


  11. islami sohbet Says:

    Thanks for writing. I worked a lot of work


  12. wow borrow someone gold Says:

    Please tell me it worked right? I dont want to sumit it again if i do not have to! Either the blog glitced out or i am an idiot, the second option doesnt surprise me lol. thanks for a great blog!


  13. building strong wooden fence gate Says:

    This is a really good read for me, Must admit that you are one of the best bloggers I ever saw.Thanks for posting this informative article.


  14. pharmacy technician jobs Says:

    My cousin recommended this blog and she was totally right keep up the fantastic work!


  15. axgrptb Says:

    SobmSM fwniekaxaijh, [url=http://npjwgdmffhov.com/]npjwgdmffhov[/url], [link=http://ceveeuvghyay.com/]ceveeuvghyay[/link], http://gwagzcqmghwg.com/


  16. Wayne Says:

    Thanks Cerah. I tried quickwebform as well and seems to good to be true. In any case, I am using it now and it works great. Do you know of any other solution or tips?


  17. Creating Simple PHP Contact Form | SmartBuzz News Feeds Says:

    [...] When you need that user contact with you or send feedback to you via email then you have to need make a contact form. In this tutorial you will learn that how to create form with php script. Overview In this tutorial create 2 files 1. contact.php and 2. send_contact.php Step 1. Create file contact.php. [...] View full post on Designs Collage [...]


Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Get Adobe Flash playerPlugin by wpburn.com wordpress themes