Contact Form Submission emailed

the mail() function

Moderators: macek, egami, gesf

New php-forum User
New php-forum User
Posts: 1
Joined: Sun Dec 04, 2011 7:34 am

Contact Form Submission emailed

Postby vjsinduja » Sun Dec 04, 2011 7:56 am

I want to have a contact form in my facebook page. I am using a free web hosting site to host my html files.
On facebook page, I create a tab where I can insert url so that, it display the html file from the free web hoster where I I have my files.

The problem I have is the mail function. I want the details submitted through that form to be emailed to me office email id(

I have WAMP installed in my computer. OS is Windows 7 Starter.

I have the html page with the form designed where there are 2 input fields

Code: Select all

<form id="form1" name="contact_form" method="post" action="mail.php">
   Name :
     <input type="text" name="name" id="name" />
  <br />
  <br />
  <br />
  Message :
    <input type="text" name="message" id="message" />
  <br />
  <br />
  <br />
    <input type="submit" name="Submit" id="Submit" value="Submit" />
    <input type="reset" name="Reset" id="button" value="Reset" />

The action page is "mail.php".
Please tell me what to do next

1. What are the attributes I need to have on the mail.php
2.What are the edit I should do on the php.ini file
3. Should hosting site should support mail()

Please guide me completely

New php-forum User
New php-forum User
Posts: 86
Joined: Sat Nov 26, 2011 8:39 am
Location: Pueblo, CO

Re: Contact Form Submission emailed

Postby kc0pph » Sun Dec 04, 2011 8:24 am

By guide completely this is the most anyone can do without writing the code for you.

Gather the POST variables from your form.
$name = $_POST['name']
$message = $_POST['message']

Prepare the Email
$to = ""
$subject = "Someone Likes you enough to send you a message"
$message = "You have a new message from". $name "<br /><br />". $message
$headers = 'From:' . "\r\n" .
'Reply-To:' . "\r\n" .
'X-Mailer: PHP/' . phpversion();

mail($to, $subject, $message, $headers)

If you cant get it to work with that abstract then make a charitable donation to my NFL Sunday Beer fund and ill write your code.

Return to “PHP coding => Mail”

Who is online

Users browsing this forum: No registered users and 1 guest