Latest Entries »

Tuesday, September 29, 2009

sample code for undestand php file handling functions

$comment = $_POST["txtcomment"];
if ($comment!=""){
$date=date('l dS \of F Y h:i:s A');
$massage = $date.": ".$comment."\n";

$file=fopen("comment.txt","a+") or exit("Unable to open file!");
fwrite($file,$massage) or die("Could not write to file");
fclose($file);
echo "Massage sent!";
}

?>

This will write the massage to the comment.txt file.

javascript mail validation (check)

var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
if (!filter.test(txtEmail.value)) {
alert('Please provide a valid email address');
txtEmail.focus();
return false;
}

use this javascript function to validate email addresses.