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 …

, , , , ,

20 Responses to “Creating Simple PHP Contact Form”

  1. 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

  2. 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.

  3. 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.

  4. Shelly Casper Says:

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

  5. Edmond Goffer Says:

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

  6. bzqdhbszdck Says:

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

  7. Dallas Cathy Says:

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

  8. Club Penguin Says:

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

  9. islami sohbet Says:

    Thanks for writing. I worked a lot of work

  10. 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!

  11. 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.

  12. pharmacy technician jobs Says:

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

  13. axgrptb Says:

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

  14. 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?

  15. Breanna Romo Says:

    amazing news brother

  16. Neomi Jalonen Says:

    Fantastic website, where did you get the theme?
    Dub Turbo Beatmaker Software Review

Trackbacks/Pingbacks

  1. Creating Simple PHP Contact Form | Blog Links - June 15, 2010

    [...] 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. Tweets that mention Creating Simple PHP Contact Form | Designs Collage -- Topsy.com - June 21, 2010

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

  3. Creating Simple PHP Contact Form | SmartBuzz News Feeds - September 1, 2010

    [...] 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 [...]

  4. 30 HTML Forms Tutorial | HTML Radar - Best Collection of HTML Tutorials on the Web - December 25, 2011

    [...] Creating Simple PHP Contact Form [...]

Leave a Reply