hello all,
kindly help me to divide this code in php and JavaScript validation ???
<?php
if(isset($REQUEST['send'])){
$status = "OK";
$y_email=$POST['y_email'];
$y_name=$POST['y_name'];
$f_name=$POST['f_name'];
$f_email=$POST['f_email'];
$y_msg=$POST['y_msg'];
if (strlen($y_name) <2 ) {
echo "<script language='javascript'>alert('Please enter your name.')</script>";
// This script is developed by Gopal Thakur
$status= "NOTOK";}
if(substr_count($y_email,"@") > 1 or substr_count($f_email,"@") > 1){
echo "<script language='javascript'>alert('Use only one email address.')</script>";
$status= "NOTOK";
}
if (!eregi("[a-z0-9-]+(.[a-z0-9-]+)@[a-z0-9-]+(.[a-z0-9-]+)(.[a-z]{2,3})$", $y_email)){
echo "<script language='javascript'>alert('Your email address is not correct or null.')</script>";
$status= "NOTOK";}
if (strlen($f_name) <2 ) {
echo "<script language='javascript'>alert('Please enter your friend's name.')</script>";
$status= "NOTOK";}
if (!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $f_email)) {
echo "<script language='javascript'>alert('Your Friends address is not correct or null')</script>";
$status= "NOTOK";}
if (strlen($y_msg) <2 ) {
echo "<script language='javascript'>alert('Please enter your message details.')</script>";
$status= "NOTOK";}[/B][B][/B]
if($status=="OK"){
$ip=$_SERVER['REMOTE_ADDR'];
$ref="http://www.abc.com/";
$header_message = "Hi $f_name \n Your friend $y_name requested you to visit the page at \n $ref \n";
$body_message =$header_message."\n".$y_msg."\n";
$headers="";
$headers4=$y_email;
$headers.="Reply-to: $headers4\n";
$headers .= "From: $headers4\n";
$headers .= "Errors-to: $headers4\n";
$subject="Request to visit URL";
mail($f_email,$subject,$body_message,$headers);
echo "<script language='javascript'>alert('Mail Send Successfully.')</script>";
}
}
?>