This site uses cookies from Google to deliver its services, to personalize ads and to analyze traffic. Information about your use of this site is shared with Google. By using this site, you agree to its use of cookies. Learn More

Php Registration Form-code-demo

Php Registration Form-code-demo Information,Tech New Php Registration Form-code-demo

PHP registration form-code-demo





PHP registration form-code-demo

<?php
//error_reporting(0);
session_start();
include "include/connection.php";
include "include/functions.php";
$fname='';
$lname='';
$dob='';
$email='';
$phone='';
$capital_city='';
$locality='';
$pwd='';
$repwd='';
$msg='';
if(isset($_POST['registration']))
{
$fname=trim($_POST['f_name']);
$lname=trim($_POST['l_name']);
if($_POST['dob']!=''){
$dob=getRevDate($_POST['dob']);
}
$email=trim($_POST['email']);
$phone=trim($_POST['phone']);
$capital_city=trim($_POST['capital_city']);
$locality=trim($_POST['locality']);
$pwd=trim($_POST['pwd']);
$repwd=trim($_POST['repwd']);

$confirm_code=md5(RandomString());


if($fname=='')
$msg='please enter first name';
else if($lname=='')
$msg='Please enter last name';
else if($dob=='')
$msg='Please enter date of birth';
else if($email=='')
$msg='Please enter email';
else if(!filter_var($email, FILTER_VALIDATE_EMAIL))
$msg='Please enter valid email';
else if(chkEmailExist('users',$email))
$msg='Email allready register';
else if($phone=='')
$msg='Please enter phone no';
else if(!is_numeric($phone))
$msg='Phone no should be numeric';
else if($capital_city=='')
$msg='Please enter capital city';
else if($pwd=='')
$msg='Please enter password';
else if(strlen($pwd)<6)
$msg='Password lenght should be minimum 6 character';
else if($repwd=='')
$msg='Please enter repassword';
else if($pwd!=$repwd)
$msg='Password and repassword should be same';
else{
echo $sql="insert into `users` set `email`='$email',`password`='$pwd',`status`='3',`confirm_code`='$confirm_code'";
$res=mysql_query($sql);
echo $user_id=mysql_insert_id();
if($res){
echo $sql1="insert into `user_profile` set `userId`='$user_id',
`firstName`='$fname',
`lastName`='$lname',
`dob`='$dob',
`email`='$email',
`phoneNo`='$phone',
`capital_city`='$capital_city',
`locality`='$locality',
`status`='2'
";

$res1=mysql_query($sql1);
$_SESSION['userId']=$user_id;
$_SESSION['UserName']=$fname;
if($res1){

$email_content_rg=getEmailContent(1);

$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=iso-8859-1" . "\r\n";
$subject=$email_content_rg['subject'];

$message ="Hi,<br/>&nbsp;&nbsp;&nbsp;".$fname." ".$lname."<br/><br/><br/>";
$message .=$email_content_rg['content'];

$message .="<br/><br/><a href='http://".$_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF'])."/confirmation.php?act=confregis&a=".urlencode($user_id)."&b=".$confirm_code."' >Please Click the link to activate your registration.. </a>";

mail($email,$subject,$message,$headers);

/*header("Location:index.php?m=rs");*/
header("Location:profile.php");
}
}else{
$msg='Registration unsuccesful';
}
}

}
//echo $msg;
?>



<?php include "include/header.php"; ?>


<div>
<div align="center">
<div>
<div>
<div>
<div>
<h4>Registration</h4>
<p>
<form name="reg" action="#" method="post">
<div>
<label>First Name</label>
<div>
<input type="text" name="f_name" value="<?php echo $fname; ?>" placeholder="First Name">
</div>
</div>

<div>
<label >Last Name</label>
<div>
<input type="text" name="l_name" value="<?php echo $lname; ?>" placeholder="Last Name">
</div>
</div>

<div>
<label >Date of birth</label>
<div>
<input type="text" name="dob" value="<?php if($dob!=''){ echo getRevDate($dob); } ?>" placeholder="Date of birth">
</div>
</div>

<div>
<label>Email</label>
<div>
<input type="text" name="email" value="<?php echo $email; ?>" placeholder="Email">
</div>
</div>

<div>
<label>Phone</label>
<div>
<input type="text" name="phone" value="<?php echo $phone; ?>" placeholder="phone">
</div>
</div>

<div>
<label>City</label>
<div>
<!--<input type="text" name="capital_city" value="<?php //echo $phone; ?>" placeholder="phone">-->
<select name="capital_city" onChange="return getLocalityList()">
<option value="">Select capital city</option>
<?php echo getCapitalCityList($capital_city); ?>
</select>
</div>
</div>

<div>
<label>Locality</label>
<div>
<!-- <input type="text" name="related_city" value="<?php //echo $phone; ?>" placeholder="phone">-->
<select name="locality">
<option value="">Select locality</option>
<?php if($capital_city!=''){ echo getLocalityList($capital_city,$locality); } ?>
</select>
</div>
</div>

<div>
<label>Password</label>
<div>
<input type="password" name="pwd" value="<?php echo $pwd; ?>" placeholder="Password"><span></span>
</div>
</div>

<div>
<label >Re-type Password</label>
<div>
<input type="password" name="repwd" value="<?php echo $repwd; ?>" placeholder="Re-type Password"><span></span>
</div>
</div>

<div>
<div>
<input type="hidden" name="registration" value="registration" >
<button type="button" onClick="subRegistraiton()">Sign in</button>
</div>
</div>
</form>
</p>
</div>
</div>
<div>
<div>
<h4>Already Registered</h4>
<p>
<form name="loginForm" action="index.php" method="post">
<div>
<label>User Id</label>
<div>
<input type="text" name="userName" placeholder="Userid">
</div>
</div>
<div>
<label >Password</label>
<div>
<input type="password" name="password" placeholder="Password">
</div>
</div>

<div>
<div>
<input type="hidden" name="login" value="login" >
<button type="button" onClick="return subLogin()">Login</button>
</div>
</div>
</form>
</p>
</div>

</div>


</div>
</div>


</div>


<?php include "include/footer.php";?>


<script src="http://code.jquery.com/jquery-latest.js"></script>
<script src="js/bootstrap.js"></script>
<!-------------------------------------------------For Date Picker----------------------------------------------------------->
<link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css" type="text/css"/>
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<!------------------------------------------------------------------------------------------------------------>
<script type="text/javascript">
$(function() {
var $j = jQuery.noConflict();
$j("#r_dob").datepicker({ dateFormat: "dd-mm-yy",changeMonth: true,changeYear: true,yearRange:'-90:+0'}).val();
});

</script>

<script>
$.noConflict();
function subRegistraiton()
{
var fname=$('#rf_name').val();
var lname=$('#rl_name').val();
var dob=$('#r_dob').val();
var email=$('#r_email').val();
var phone=$('#r_phone').val();
var capital_city=$('#r_capital_city').val();
var locality=$('#r_locality').val();
var pwd=$('#r_pwd').val();
var repwd=$('#r_repwd').val();
var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;

if(fname=='')
{
alert('Please enter first name');
$('#rf_name').focus();
return false;

}
else if(lname=='')
{
alert('Please enter last name');
$('#rl_name').focus();
return false;
}
else if(dob=='')
{
alert('Please enter date of birth');
$('#r_dob').focus();
return false;
}
else if(email=='')
{
alert('Please enter email');
$('#r_email').focus();
return false;
}
else if(!filter.test(email))
{
alert('Please provide a valid email address');
// $('#r_email').val('');
$('#r_email').focus();
return false;
}
else if(phone=='')
{
alert('Please enter phone no');
$('#r_phone').focus();
return false;
}
else if(phone.length!=10)
{
alert('Phone number should be 10 digits');
$('#r_phone').focus();
return false;
}
else if(capital_city=='')
{
alert('Please select capital city');
$('#r_capital_city').focus();
return false;
}
else if(pwd=='')
{
alert('Please enter password');
$('#r_pwd').focus();
return false;
}
else if(pwd.length < 8)
{
alert("Please enter at least 8 characters");
$('#r_pwd').val('');
$('#r_pwd').focus();
return false;
}
else if(repwd=='')
{
alert('Please enter re-password');
$('#r_repwd').focus();
return false;
}
else if(pwd!=repwd)
{
alert('Password and repassword does not match');
$('#r_repwd').val('');
$('#r_repwd').focus();
return false;
}else{

document.reg.submit();
$.loader();
// setTimeout( "$.loader('close');",20000 );
}


}

function subLogin()
{
var userName=$("#l_userName").val();
var password=$("#l_password").val();

if(userName==''){
alert('Please enter username');
$("#l_userName").focus();
return false
}
else if(password=='')
{
alert('Please enter password');
$("#l_password").focus();
return false;
}else{
document.loginForm.submit();
$.loader();
// setTimeout( "$.loader('close');",10000 );
}
}


function getLocalityList()
{
var capitalCity=$("#r_capital_city").val();

$.ajax({
type: 'POST',
url: 'ajax/ajax_cityList.php',
data: {'capital_city' : capitalCity ,'action' : 'locality'},
success: function(data){
$("#r_locality").html(data);
}
});

}
</script>


<script>
<?php
if($msg!=''){
?>
alert('<?php echo $msg; ?>');
<?php
}
?>
</script>

<script>
$(function(){
$(window).keypress(function(ev){
if(ev.charCode == 99)
{
$.loader('close');
}
});
$('#test1button1').click(function(){
$.loader();
setTimeout( "$.loader('close');",3000 );
});

});
</script>

0 Response to "Php Registration Form-code-demo"

Posting Komentar

Contact

Nama

Email *

Pesan *