How to Code Contact.php Form

Hi I’m trying to code a contact form for my website and have got it looking fantastic but I’m not sure how to code in my php so that it will actually submit the form to my email. Would love any tips or help

Here’s my contact.php form

<title>Contact Form</title>
<link rel="STYLESHEET" type="text/css" href="contact.css" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script src="mootools-yui-compressed.js" ></script>
<script src="validation.js" ></script>
<script type="text/javascript">
	var nameError = 'Please enter a Name to proceed.';
	var emailError = 'Please enter a valid Email Address to continue.';
	var commentError = 'Please enter your Message to continue.';
</script>
Say something nice...
#

Well, first, in your code for your email fields, you “name” them. as you did.
For example, name=“fullname”…
In your PHP code, you would “capture” this field by using $_POST[‘fullname’].
This allows you to assign the values of the fields in your HTML form to variables in your PHP code.
Something like: $fullname=$_POST[‘fullname’];

Next, you take all of the fields that have been converted into PHP variables and build your email message.
Then, mail the email and redirect to a “message-has-been-sent” page that tells the user all is okay.

Of course, you must do some validation to make sure they entered all the correct data first.

Here is a site that explains it in very simple terms. I think it will help you out.
http://www.w3schools.com/php/php_mail.asp
(Note: This site has short, simple tutorials on just about everything!)

Good luck… Post back if it works or if you need further help with it. (Just post your new code inside the PHP tags!)

Sponsor our Newsletter | Privacy Policy | Terms of Service