sridharao
Jun 16th, 2008, 07:42 PM
I have the following code being used for validating a form:
if (isset($_POST['AddEntry'])) {
$emai = stripslashes($_POST['YourEmail']);
$namm = stripslashes($_POST['YourName']);
$commt = ($_POST['YourComment']);
if (!preg_match("/[A-Za-z]*/", $namm)) {
die ('<p align="center">Sorry, Please enter text without any symbols or special characters.</p>'); //THIS ISN'T WORKING
}else{
$nam = $namm;
}
if (!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$",$emai)){
die ('<p align="center">There is something wrong with your email ID, please check it.</p>');
}
list($userName, $mailDomain) = split("@", $emai);
if (!myCheckDNSRR($mailDomain, "MX")) {
die ('<p align="center">Sorry, this email ID failed validation. Please provide correct email ID.</p>');
}
if (!preg_match("/[A-Za-z]*/", $commt)) {
die ('<p align="center">Sorry, Please enter text without any symbols or special characters.</p>');
}else{
$comt = $commt;
}
this is the function to check dnserror:
function myCheckDNSRR($hostName, $recType = ''){
if(!empty($hostName)) {
if( $recType == '' ) $recType = "MX";
exec("nslookup -type=$recType $hostName", $result);
foreach ($result as $line) {
if(eregi("^$hostName",$line)) {
return true;
}
}
return false;
}
return false;
}
I found this script on the net for windows based servers, this script is failing despite providing a valid domain name.
if (isset($_POST['AddEntry'])) {
$emai = stripslashes($_POST['YourEmail']);
$namm = stripslashes($_POST['YourName']);
$commt = ($_POST['YourComment']);
if (!preg_match("/[A-Za-z]*/", $namm)) {
die ('<p align="center">Sorry, Please enter text without any symbols or special characters.</p>'); //THIS ISN'T WORKING
}else{
$nam = $namm;
}
if (!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$",$emai)){
die ('<p align="center">There is something wrong with your email ID, please check it.</p>');
}
list($userName, $mailDomain) = split("@", $emai);
if (!myCheckDNSRR($mailDomain, "MX")) {
die ('<p align="center">Sorry, this email ID failed validation. Please provide correct email ID.</p>');
}
if (!preg_match("/[A-Za-z]*/", $commt)) {
die ('<p align="center">Sorry, Please enter text without any symbols or special characters.</p>');
}else{
$comt = $commt;
}
this is the function to check dnserror:
function myCheckDNSRR($hostName, $recType = ''){
if(!empty($hostName)) {
if( $recType == '' ) $recType = "MX";
exec("nslookup -type=$recType $hostName", $result);
foreach ($result as $line) {
if(eregi("^$hostName",$line)) {
return true;
}
}
return false;
}
return false;
}
I found this script on the net for windows based servers, this script is failing despite providing a valid domain name.