Friday, 17 February 2017

Validation and Insertion in PHP




Email Validation in PHP using eregi function



<?php
include"connect.php";

$name=$_GET['txtname'];
$add=$_GET['txtadd'];
$mo=$_GET['txtmno'];
$g=$_GET['radg'];
$email=$_GET['txtemail'];
$dt=$_GET['dd']."/".$_GET['mm']."/".$_GET['yy'];
$un=$_GET['txtuname'];
$pass=$_GET['txtpass'];
$cpass=$_GET['txtcpass'];

//(ereg("^[a-zA-Z ]$",$name)) && (ereg("^[7-9]?[0-9]{9}$",$mo)))


//eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9]+)*(\.[a-z]{2,3})$",$email)))

//echo "$name </br>$add</br>$mo</br>$g</br>$email</br>$dt</br>$un</br>$pass</br>$cpass</br>";

if($name!="" && $add!="" && $mo!="" && $g!="" && $email!="" && $dt!="" && $un!="" && $pass!="" && $pass===$cpass)
{

    if((eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9]+)*(\.[a-z]{2,3})$",$email)) && (ereg("^[a-zA-Z ]+$",$name)) && (ereg("^[7-9]?[0-9]{10}$",$mo)))
    {
        $r=pg_query($con,"insert into Users values('$name','$add','$mo','$g','$email','$dt','$un','$pass')");
        if($r)
        {
        echo "<script type='text/javascript'>";
        echo "if(confirm('You are registered Successfully'))document.location='career.html';else document.location='career.html';";
        echo "</script>";
        }   
        else
        {
        echo "<script type='text/javascript'>";
        echo "if(confirm('Something Wrong'))document.location='index.html';else document.location='index.html';";
        echo "</script>";
       
        }
    }
    else
    {

        echo "<script type='text/javascript'>";
        echo "if(confirm('email or name or mobile invalid'))document.location='index.html';else document.location='index.html';";
        echo "</script>";
    }


}
else
{
    echo "<script type='text/javascript'>";
    echo "if(confirm('Fields should not be empty'))document.location='index.html';else document.location='index.html';";
    echo "</script>";

}
?>

No comments:

Post a Comment

Note: only a member of this blog may post a comment.