Php Contact form

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
lakshkhamesra
Forum Newbie
Posts: 7
Joined: Fri Mar 26, 2010 5:54 pm

Php Contact form

Post by lakshkhamesra »

I have this html contact form:-
"""'''''''
<form action="submitted.html" method="post">
<input name="textfield" type="text" class="inp" id="textfield" />
<input name="textfield2" type="text" class="inp" id="textfield2" />
<input name="textfield3" type="text" class="inp" id="textfield3" />
<input name="textfield4" type="text" class="inp" id="textfield4" />
<textarea name="textarea" cols="45" rows="5" class="inp" id="textarea"></textarea>
<input name="textfield5" type="text" class="inp" id="textfield5" />
<input type="image" name="submit" src="images/submit.jpg" width="45" height="20" />
</form>
"""'''''''

I want that when user clicks on the 'submit' button, all info goes to my email address.
Please help me. I tried googling it but all codes I found are too tricky for me.
Your help will be highly appreciated.
Thank you in advance.
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: Php Contact form

Post by Celauran »

Where is your PHP? Where is it failing? What's the problem, exactly?
User avatar
spedula
Forum Commoner
Posts: 81
Joined: Mon Mar 29, 2010 5:24 pm

Re: Php Contact form

Post by spedula »

First off, like said before. Please post your PHP code.

Secondly, your action on the form is posting to an HTML file, unless your .htaccess is configured to parse html files as PHP, this won't work no matter what your code you have in submitted.html

Now, for the juicy part.

Code: Select all


//Post's info from form.
$textfield = $_POST['textfield'];
$textfield2 = $_POST['textfield2'];
$textfield3 = $_POST['textfield3'];
$textfield4 = $_POST['textfield4'];
$textfield5 = $_POST['textfield5'];
$textarea = $_POST['textarea'];

$subject = 'Your form has been filled out.';
$to = 'YOUREMAIL@ADDRESS.COM';
$from = 'Your Self';

//Sends Emails.
$headers  = "From: $from\r\n"; 
$headers .= "X-Priority: 3\r\n";
$headers .= "X-MSMail-Priority: Normal\r\n";
$message = $textfield.'<br />'.$textfield2.'<br />'.$textfield3.'<br />'.$textfield4.'<br />'.$textfield5.'<br />'.$textarea;
mail($to, $subject, $message, $headers);


Post Reply