# PHP Required Form Fields

**URL:** <https://forum.kirupa.com/t/php-required-form-fields/224370>\
**Category:** programming\
**Created:** [May 1, 2007, 9:04pm UTC](https://forum.kirupa.com/t/php-required-form-fields/224370 "2007-05-01T21:04:57Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![crowdm77](https://avatars.discourse-cdn.com/v4/letter/c/f07891/32.png) [@crowdm77](https://forum.kirupa.com/u/crowdm77)\
**Post date:** [May 1, 2007, 9:04pm UTC](https://forum.kirupa.com/t/php-required-form-fields/224370/1 "2007-05-01T21:04:57Z")

</div>

Hey everyone. First post to Kirupa. Thought I’d give it a shot. I have been working on trying to validate some form fields in a PHP form (without using flash). Does anyone have the code for this? Below is the code I have now that works perfect to send an email out from a form, but doesn’t validate.

[FONT=Courier New][SIZE=2][COLOR=Red]\<?php  
if(isset($\_POST[‘submit’])) {

$to = "hi@yahoo.com";  
$subject = “Request A Quote”;  
$name\_field = $\_POST[‘name’];  
$company\_field = $\_POST[‘company’];  
$business\_field = $\_POST[‘business’];  
$areacode\_field = $\_POST[‘areacode’];  
$phone\_field = $\_POST[‘phone’];  
$email\_field = $\_POST[‘email’];

foreach($\_POST[‘check’] as $value) {  
$check\_msg .= "Checked: $value  
";  
}

$budget = $\_POST[‘selectBudget’];  
$heard = $\_POST[‘selectHeard’];

$message = $\_POST[‘message’];

$body = "From: $name\_field  
Company: $company\_field  
Type of Business: $business\_field  
Areacode: $areacode\_field  
Phone: $phone\_field  
E-Mail: $email\_field  
Service Desired: $check\_msg  
Budget: $budget  
Heard: $heard  
Message: $message  
";

echo “Data has been submitted to $to!”;  
mail($to, $subject, $body);

} else {

echo “blarg!”;

}  
?\>[/COLOR][/SIZE][/FONT]
