PHP Form processor Dreamweaver validation

Hello I am new to PHP and I have followed tutorials to create a form processor to send information from my HTML contact form to my E mail address. It is working great and sending all form fields to the email address, my problem comes in while trying to validate the submit button with Dreamweaver CS5’s behavior (validate form). My contact form can be populated with the wrong information and it will still submit the data to my E mail address. I would like to prevent the form from being submitted without the proper information input.

This is the contact form HTML.

	<div id="contact">
    		 <form action="contactformprocess.php" method="post">
            <fieldset> 
            <legend><h2>Fields marked with an * are required.</h2></legend><br />
			
				<label id="name">*First and Last Name:</label>
	    <input name="name" type="text" id="name" /><br />
                    
	   			 <label id="email">*Email Address:</label>
        <input name="email" type="text" id="email" /><br />
                  
				<label id="phone">Phone Number:</label>
				  <input name="phone" type="text" id="phone" /><br />
                  
				<label	 id="company">Company Name:</label>
				 <input name="company" type="text" id="company" /><br />
                 
                 <label	 id="url">Current URL:</label>
				  <input name="url" type="text" id="url" /><br />
                    
				<label	 id="city">*City:</label>
          <input name="city" type="text" id="city" /><br /> 
                                           
				<label	 id="state">*State:</label>                   
					<select name="state" class="dropdown" id="state">
					<option>Select One</option>
					<option value="AZ">AZ</option>
					<option value="NM">NM</option>
				  <option value="TX">TX</option></select><br />
                    
                <label	 id="interested">Interested In:</label>
			  <input name="interested" type="text" id="interested" /><br /> 
                    <br />
                <label	 id="budget">Your Budget is:</label>                   
					<select name="budget" class="dropdown" id="budget">
					<option>Select One</option>
                    <option>Not Sure Yet</option>
                    <option>$650 - $1,500</option>
                    <option>$1,500 - $3,000</option>
                    <option>$3,000 - $5,000</option>
                    <option>$5,000 - $10,000</option>
              <option>$10,000 - $20,000</option></select><br />
					<br />    
  
                    
				<br />
				<label id="comments">*Questions/Comments:</label><textarea name="comments" cols="20" rows="2" id="comments"></textarea><br />
					<input name="button" type="submit" class="submit" id="button" onclick="MM_validateForm('name','','R','email','','RisEmail','city','','R','comments','','R');return document.MM_returnValue" value="Submit this form" /></fieldset></form>
                    
	</div>

This is the PHP form processor code.

<?php

/* Contact Page PHP Script */

/* Email Variables */
$emailSubject = ‘contactformprocess!’; /Make sure this matches the name of your file/
$webMaster = ‘ramaxey@ramediaworks.com’;

/* Data Variables */
$name = $_POST[‘name’];
$email = $_POST[‘email’];
$phone = $_POST[‘phone’];
$company = $_POST[‘company’];
$url = $_POST[‘url’];
$city = $_POST[‘city’];
$state = $_POST[‘state’];
$interested = $_POST[‘interested’];
$budget = $_POST[‘budget’];
$comments = $_POST[‘comments’];

$body = <<<EOD
<br><hr><br>
Name: $name <br>
Email: $email <br>
Phone: $phone <br>
Company: $company <br>
Url: $url <br>
City: $city <br>
State: $state <br>
Interested: $interested <br>
Budget: $budget <br>
Comments: $comments <br>
EOD;

$headers = "From: $email\\r\

";
$headers .= "Content-type: text/html\r
";
$success = mail($webMaster, $emailSubject, $body,
$headers);

/* Results rendered as HTML /
$theResults = <<<EOD
<html>
<head>
<title>Ray Anthoney Media Works Sent Message</title>
<meta http-equiv=“refresh” content=“5;URL=http://www.ramediaworks.com/index.html”>
<style type=“text/css”>
<!–
body {
background: #929094 url(…/images/body1.jpg); /
You can edit this CSS to match your website*/
font-family: Tahoma,sans-serif;
font-size: 20px;
font-style: normal;
line-height: normal;
font-weight: normal;
color: #FFF;
text-decoration: none;
padding-top: 200px;
margin-left: 150px;
width: 800px;
}
–>
</style>
</head>
<div align=“center”>Thank you for your Interest. Your email will be answered very soon. You will now be returned to Ray Anthoney Media Works home page.</div>
</div>
</body>
</html>
EOD;
echo “$theResults”;
?>

Can someone tell me where I am going wrong or lead me in the right direction?

Thanks,

You need to add some extra lines to the PHP script to check that the data in each filed is valid—that is, that it contains what you want it to and doesn’t contain anything it shouldn’t. This is called form validation. It can be fairly simple, such as requiring the field not to be empty, or it can be very strict, ensuring that the submitted content follows a strict pattern, such as the pattern of an email address for an email input.

Here is a simple example page: http://www.phpf1.com/tutorial/php-form.html?page=3