AddThis

Share |

Sunday, July 4, 2010

signup_action.php


signup_action.php




<?php
include("connect.php");
//variable define
$userName=$_REQUEST['userName'];
$userEmail=$_REQUEST['userEmail'];
$userPassword1=$_POST['userPassword1'];
$userPassword2=$_POST['userPassword2'];
$password=md5($userPassword1);

// .......................Email validation.................


function isValidEmail($userEmail)
{
$pattern = "^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*
(\.[a-z]{2,3})$";
if (eregi($pattern, $userEmail))
{
return true;
}
else
{
return false;
}
}

// .......................Error Message.....................
//start error message
$error=false;
$errorMessage="";

if(empty($userName))
{
$error=true;
$userNameError=true;
$errorMessage.="Please provide username.</br>";
}
if(empty($userEmail))
{
$error=true;
$userEmailError=true;
$errorMessage.="Please provide email.</br>";
}
if($userPassword1=="")
{
$error=true;
$userPassword1Error=true;
$errorMessage.="Please provide password.</br>";
}

/*if($userPassword1)
{
if(preg_match("/^.*(?=.{8,})(?=.*[a-z]+)(?=.*[^A-Za-z0-9])
(?=.*[0-9\.\-\@\#\$\&]).*$/",$userPassword1))
{
$successMessage.= "Successfuly checked your password.
U have to login now";
}
{
$error=true;
$paswordValidationError=true;
$errorMessage.= "Please Enter"."<br />"."Atleast 8 character"."
<br/>"."Alpha numeric value"."<br />"."1 Special character";
}
}
*/
if($userPassword1!=$userPassword2)
{
$error=true;
$passwordMatchingError=true;
$errorMessage.="Password does not match.</br>";

}


if(!isValidEmail($userEmail))
{
$error=true;
$emailValidationError=true;
$errorMessage.="Invalid email id.</br>";
}
//end error message

//start insert data
if($error)
{
include("index.php");
}
else
{
$sql="insert into sign_up
(
userName,
userEmail,
password

)
values

(
'$userName',
'$userEmail',
'$password'
)
";


$result=mysql_query($sql);
if($sql)
{
echo "Successfully inserted";

//end insert data
?>

<script language="javascript">
window.location="message.php";
</script>
<?php
}
}
?>

0 comments:

Post a Comment