Email message in a html table format


—————–html form ———————————————-

<form action=”””” method=””post””>
<label>Name:*</label>
<input id=””name”” name=””name”” type=””text”” />
<label>Business Name (if any)</label>
<input name=””businessname”” type=””text”” />
<label>Phone:*</label>
<input id=””phone”” name=””phone”” type=””text”” />
<label>Email Address:*</label>
<input id=””email”” name=””email”” type=””text”” />
<label>Message</label>
<textarea style=””width: 245px;” name=””message””></textarea>

</form>

----------------- php part -------------------------------
&lt;?php
if (isset($_POST['submit'])) {

$to =  &quot;amamun_cse@yahoo.com&quot;;
$fromemail = $_POST['email'];
$name = $_POST['name'];
$bname = $_POST['businessname'];
$phone = $_POST['phone'];
$message = $_POST['message'];

$headers  = &quot;MIME-Version: 1.0\r\n&quot;;
$headers .= &quot;Content-type:text/html; charset=iso-8859-1\r\n&quot;;
$headers .= &quot;From: $name\r\n";

//$headers = $fromemail;

$subject="SIM Card subscription and purchase confirmation email";

$body = "<table width="450" cellpadding="0" cellspacing="0" border="0" style='border-collapse:collapse;'>";
$body .= "<tr><td align="left"> <strong> Dear 'Admin', </strong> </td></tr>";
$body .= "<tr><td align="left">$name </td> </tr><tr>";
$body .= "<tr><td align="left">$bname</td> </tr><tr>";
$body .= "<tr><td>$phone</td> </tr>";
$body .= "<tr><td>$message</td> </tr>";
$body .="</table>";

$sent = @mail($to,$subject,$body,$headers);

$msg = "Successfully Sent";
}

?&gt;

———– Validation ——————————–

//email validation
function echeck() {

//alert(str);

var name = document.getElementById("name").value;
var phone = document.getElementById("phone").value;
var email = document.getElementById("email").value;

if (name.length == ""){

alert("Name field is empty")
return false
}

if (phone.length == ""){

alert("Phone field is empty")
return false
}

var at="@"
var dot="."
var lat=email.indexOf(at)
var lemail=email.length
var ldot=email.indexOf(dot)

if (email.indexOf(at)==-1){

alert("Invalid E-mail ID")
return false
}

if (email.indexOf(at)==-1 || email.indexOf(at)==0 || email.indexOf(at)==lemail){
alert("Invalid E-mail ID")
return false
}

if (email.indexOf(dot)==-1 || email.indexOf(dot)==0 || email.indexOf(dot)==lemail){
alert("Invalid E-mail ID")
return false
}

if (email.indexOf(at,(lat+1))!=-1){
alert("Invalid E-mail ID")
return false
}

if (email.substring(lat-1,lat)==dot || email.substring(lat+1,lat+2)==dot){
alert("Invalid E-mail ID")
return false
}

if (email.indexOf(dot,(lat+2))==-1){
alert("Invalid E-mail ID")
return false
}

if (email.indexOf(" ")!=-1){
alert("Invalid E-mail ID")
return false
}

return true
}
//**********end of email validation****************************