Please help -
I have the following code and i need to make all text field except the company name mandatory and also validate the email address is correct - and any errors to display a message to tell the user what they have done wrong.
Thanks
<?
$fromname=$_POST['fromName'];
$fromcompany=$_POST['fromCompany'];
$toemail='info@advantageinvestigation.co.uk';
$fromemail=$_POST['fromEmail'];
$fromPhone=$_POST['fromPhone'];
$subject='HTML feedback';//$_POST['subject'];
$body= "\nMail From :".$fromname.'<br>';
$body.="Company: ". $fromcompany.'<br>';
$body.="Phone: ". $fromPhone.'<br>';
$body.="Message: ".$_POST['body'];
$status = "Message Sent!\nThank you";
$headers = "MIME-Version: 1.0\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\n";
$headers .= "From: " . $fromemail . "\n";
?>
<html>
<head>
<title>Welcome to Advantage Investigation</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" type="text/css" href="file:///E|/ADVANTAGE%20INVESTIGATIONS/style.css">
<style type="text/css">
<!--
body,td,th {
font-size: 11px;
}
-->
</style></head>
<body>
<table border="0" cellspacing="0" cellpadding="0" width="100%" height="100%">
<tr>
<td align="center" valign="middle"><table border="0" cellspacing="0" cellpadding="0" align="center" height="571">
<tr><td height="100%" valign="top" style="padding-bottom:53px;padding-top:53px "><table height="100%" border="0" cellpadding="0" cellspacing="0" >
<tr>
<td valign="top" ><img src="file:///E|/ADVANTAGE%20INVESTIGATIONS/images/m_top.gif"></td>
</tr>
<Tr><Td height="100%" valign="top"><table height="100%" border="0" cellpadding="0" cellspacing="0">
<tr><Td><img src="file:///E|/ADVANTAGE%20INVESTIGATIONS/images/m_left.gif"></Td><td width="100%" height="100%" valign="top"><table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td height="100%" valign="top" ><table height="100%" border="0" cellpadding="0" cellspacing="0" >
<tr>
<td width="232" height="100%" valign="top" ><table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td bgcolor="#505050"><img src="file:///E|/ADVANTAGE%20INVESTIGATIONS/images/logo.gif" style="margin-left:4px ;margin-bottom:2px"></td>
</tr>
<tr><Td valign="top" bgcolor="#5D5D5D" align="right"><a href="file:///E|/ADVANTAGE%20INVESTIGATIONS/home.html"><img src="file:///E|/ADVANTAGE%20INVESTIGATIONS/images/but1.gif" border="0"></a><br>
<a href="file:///E|/ADVANTAGE%20INVESTIGATIONS/services.html"><img src="file:///E|/ADVANTAGE%20INVESTIGATIONS/images/but2.gif" border="0"></a><br>
<a href="file:///E|/ADVANTAGE%20INVESTIGATIONS/price.html"><img src="file:///E|/ADVANTAGE%20INVESTIGATIONS/images/but3.gif" border="0"></a><br>
<a href="file:///E|/ADVANTAGE%20INVESTIGATIONS/contact.php"><img src="file:///E|/ADVANTAGE%20INVESTIGATIONS/images/but4.gif" border="0"></a><br>
</Td></tr>
<tr><td valign="bottom" height="100%" bgcolor="#5D5D5D"><img src="file:///E|/ADVANTAGE%20INVESTIGATIONS/images/pic_1.jpg"></td></tr>
<Tr><Td valign="top"><img src="file:///E|/ADVANTAGE%20INVESTIGATIONS/images/copyright.gif"></Td></Tr>
</table>
</td>
<td valign="top" width="403" bgcolor="#FFFFFF"><form style="padding:0;margin:0 " name="form" method="post" action="file:///E|/ADVANTAGE%20INVESTIGATIONS/contact.php"><table border="0" cellspacing="0" cellpadding="0" style="margin-left:28px;margin-top:30px; margin-right:18px " width="357">
<tr>
<td><img src="file:///E|/ADVANTAGE%20INVESTIGATIONS/images/con_us.gif" width="90" height="37"></td>
</tr>
<tr><Td height="1" background="file:///E|/ADVANTAGE%20INVESTIGATIONS/images/dot.gif"><img src="file:///E|/ADVANTAGE%20INVESTIGATIONS/images/spacer.gif"></Td></tr>
<tr><Td valign="top" style="padding-left:0px;padding-top:13px;padding-bottom:15px"><p><img src="file:///E|/ADVANTAGE%20INVESTIGATIONS/images/mail_addr.gif" width="106" height="23"><br>
<img src="file:///E|/ADVANTAGE%20INVESTIGATIONS/images/3_pic_1.jpg" align="left" style="margin-right:6px "></p>
<p>Address: Po Box 624, Hull, HU5 5WS<br>
<br style="line-height:3px ">
Tel: 01482 566071 <br>
<br style="line-height:3px ">
Fax: 01482 574276 <br>
<br style="line-height:3px ">
Mobile: 07812 031 787<br>
<br style="line-height:3px ">
Email: <a href="mailto:info@advantageinvestigation.co.uk">info@advantageinvestigation.co.uk</a><br>
</p></Td></tr>
<tr><Td height="1" background="file:///E|/ADVANTAGE%20INVESTIGATIONS/images/dot.gif"><img src="file:///E|/ADVANTAGE%20INVESTIGATIONS/images/spacer.gif"></Td></tr>
<tr><Td valign="top" style="padding-left:0px;padding-top:13px;padding-bottom:2px"><img src="file:///E|/ADVANTAGE%20INVESTIGATIONS/images/conform.gif" width="106" height="23"><br>
<?
if($_POST['submitted'])
{
$response= mail($toemail, $subject, $body, $headers);
if ($response==false){
$status="<div align='center'>Error in sending mail</div>";
}
else
{
print "<div align='center'>Thank you for your email<br><br></div>
";
}
}
?>
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td valign="top" width="87" style="padding-top:4px">Your Name:</td>
<td valign="top" style="padding-left:4px;padding-bottom:9px"><input type="text" class="inp" name="fromName"></td>
</tr>
<tr>
<td valign="top" width="87" style="padding-top:4px">Company Name:</td>
<td valign="top" style="padding-left:4px;padding-bottom:9px"><input type="text" class="inp" name="fromCompany"></td>
</tr>
<tr>
<td valign="top" width="87" style="padding-top:4px">E-mail Address:</td>
<td valign="top" style="padding-left:4px;padding-bottom:9px"><input type="text" class="inp" name="fromEmail"></td>
</tr>
<tr>
<td valign="top" width="87" style="padding-top:4px">Telephone:</td>
<td valign="top" style="padding-left:4px;padding-bottom:9px"><input type="text" class="inp" name="fromPhone"></td>
</tr>
<tr>
<td valign="top" width="87" style="padding-top:4px">Your Message:</td>
<td valign="top" style="padding-left:4px;padding-bottom:0px"><textarea class="inp" style="height:65px;overflow:auto " name="body"></textarea><INPUT type="hidden" name="submitted" value="1"></td>
</tr>
</table></Td></tr>
<tr><Td height="1" background="file:///E|/ADVANTAGE%20INVESTIGATIONS/images/dot.gif"><img src="file:///E|/ADVANTAGE%20INVESTIGATIONS/images/spacer.gif"></Td></tr>
<Tr><Td valign="top" style="padding-center:9px;padding-top:2px" align="center"><div align="center">
<input type="image" src="file:///E|/ADVANTAGE%20INVESTIGATIONS/images/send.gif" onClick="document.form['form'].submit();">
<input type="image" src="file:///E|/ADVANTAGE%20INVESTIGATIONS/images/clear.gif" onClick="document.form['form'].reset();">
</div></Td>
</Tr>
</table>
</form>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td><Td><img src="file:///E|/ADVANTAGE%20INVESTIGATIONS/images/m_right.gif"></Td></tr></table>
</Td></Tr>
<tr><td valign="top"><img src="file:///E|/ADVANTAGE%20INVESTIGATIONS/images/m_bot.gif"></td>
</tr>
</table>
</td>
</table>
</td>
</tr>
</table>
</body>
</html>