<?php
session_start();
include("connection.php");
$error="";
?>
<?php if (isset($error)) { echo "<p class='message'>" .$error. "</p>" ;} ?>
<?php
ini_set("display_errors",0);
if(isset($_POST['btnadd']))
{
// $txtname=$_POST['txtname'];
$txtname=$_POST['txtname'];
$txtuname=$_POST['txtuname'];
$txtemail=$_POST['txtemail'];
$txtphonenum=$_POST['txtphonenum'];
$txtadd=$_POST['txtadd'];
$txtcode=$_POST['txtcode'];
$txtabout=$_POST['txtabout'];
$txtpass=$_POST['txtpass'];
$txtconpass=$_POST['txtconpass'];
$file=$_FILES['file']['name'];
$rand=rand(1,5000000);
$img=$rand.$file;
move_uploaded_file($_FILES['file']['tmp_name'],"imag/".$img);
$pass=$_POST['txtconpass'];
// $date = date('Y-m-d H:i:s');
$status='Active';
if($txtname == "")
{
// null chak name field
echo $error="Please Enter name";
$code="1";
}
elseif(!preg_match("/^[a-zA-Z]+$/",$txtname))
{
// chack name field only char
echo $first_nameErr = "Only letters allowed";
$code="1";
}
elseif($txtemail=="")
{
echo $error="Please Enter Email";
$code="2";
}
elseif(!preg_match("/^[_\.0-9a-zA-Z-]+@([0-9a-zA-Z][0-9a-zA-Z-]+\.)+[a-zA-Z]{2,6}$/i",$txtemail))
{
echo $error ="Please Enter valid Email";
$code="2";
}
elseif($txtphonenum=="")
{
echo $error= "Please Enter Mobile Number";
$code="3";
}
elseif(!preg_match("/^\d{10}$/",$txtphonenum))
{
echo $error = "Please Enter 10 Digit number";
$code= "3";
}
elseif(trim($txtadd)=="")
{
echo $error="Please Enter Your Address";
$code="4";
}
elseif(strlen($txtadd) < 60)
{
echo $error = "Please at least 60 word write";
$code = "4";
}
elseif($txtcode=="")
{
echo $error ="Please Enter Pincode ";
$code= "5";
}
elseif(!preg_match("/^\d{6}$/",$txtcode))
{
echo $error = "Enter must be 6 Digit";
$code = "5";
}
elseif(trim($txtabout)=="")
{
echo $error = "Please enter a About me";
$code="6";
}
elseif(strlen($txtabout) < 120)
{
echo $error = "Please at least 120 word write";
$code = "6";
}
elseif($txtpass=="")
{
echo $error= "Please Enter password";
$code = "7";
}
elseif(strlen($txtpass) < 8)
{
echo $error = "Please at lease 8 char length";
$code = "7";
}
elseif($txtconpass=="")
{
echo $error = "Please Enter confirm password";
$code= "8";
}
elseif($txtconpass !=$txtpass)
{
echo $error = "Your Password is not match";
$code = "8";
}
elseif(!preg_match("/[0-9a-zA-Z]/",$txtconpass))
{
echo $error= "Please Enter Char";
$code = "8";
}
elseif(!preg_match("/[@$,<>#:?_*&;]/",$txtconpass))
{
echo $error = "Pleace Enter at least one special char ";
$code = "8";
}
else
{
$sql="insert into reg(name,uname,uemail,phonenum,address,postcode,aboutme,pimage,pass,rdate,status) values('$txtname','$txtuname','$txtemail','$txtphonenum','$txtadd','$txtcode','$txtabout','$img','$txtconpass',now(),'$status')";
$sqlexcu=mysqli_query($dd,$sql);
echo "submit";
}
if(!$sqlexcu)
{
echo mysql_error();
}
else {
echo "<script>alert('Your Registration successfully');</script>";
}
}
?>
<style type="text/css" >
.error{border:1px solid red; }
.message{color: red; font-weight:italite;}
</style>
<form name="f2" id="f2" method="post" enctype="multipart/form-data" style=" margin-top: -100px;" onsubmit="return chkform(this);">
<table border="1">
<tr>
<th colspan="2">Registration Form</th>
</tr>
<tr>
<th>Name</th>
<td><input type="text" name="txtname" placeholder="Enter Name" value="<?php if(isset($txtname)) { echo $txtname; } ?>" <?php if(isset($code) && $code == 1){echo "class=error";} ?> /></td>
</tr>
<tr>
<th>User Name</th>
<td><input type="text" name="txtuname" placeholder="Enter User Name" onblur="userchaked(this.value)"/></td>
<span id="msg"></span>
</tr>
<tr>
<th>Email</th>
<td><input type="text" name="txtemail" placeholder="Enter email Addres" value="<?php if(isset($txtemail)) { echo $txtemail; } ?>" <?php if(isset($code) && $code == 2){echo "class=error";} ?> /> </td>
</tr>
<tr>
<th>Phone number</th>
<td><input type="text" name="txtphonenum" placeholder="Enter Phone number" value="<?php if(isset($txtphonenum)) { echo $txtphonenum; } ?>" <?php if(isset($code) && $code == 3) { echo "class=error"; } ?> /> </td>
</tr>
<tr>
<th>Address</th>
<td><textarea name="txtadd" <?php if(isset($code) && $code == 4) { echo "class=error"; } ?> > <?php if(isset($txtadd)) { echo $txtadd; } ?> </textarea></td>
</tr>
<tr>
<th>Post code</th>
<td><input type="text" name="txtcode" placeholder="Enter Postal Code" value="<?php if(isset($txtcode)) { echo $txtcode; } ?>" <?php if(isset($code) && $code == 5) { echo "class=error"; } ?> /></td>
</tr>
<tr>
<th>About Me</th>
<td><textarea name="txtabout" <?php if(isset($code) && $code == 6) { echo "class=error"; } ?> > <?php if(isset($txtabout)) { echo $txtabout; } ?> </textarea></td>
</tr>
<tr>
<th>Profile Image</th>
<td><input type="file" name="file" id="imgfile" onchange="readURL(this)";/></td>
<img id="preview" src="#" alt="." />
</tr>
<tr>
<th>Password</th>
<td><input type="password" name="txtpass" placeholder="Enter Password" value="<?php if(isset($txtpass)) { echo $txtpass; } ?>" <?php if(isset($code) && $code == 7) { echo "class=error"; } ?> /></td>
</tr>
<tr>
<th>Confirm Password</th>
<td><input type="password" name="txtconpass" placeholder="Enter Confirm password" value="<?php if(isset($txtconpass)) { echo $txtconpass; } ?>" <?php if(isset($code) && $code == 8) { echo "class=error"; } ?> /></td>
<input type="hidden" name="a1" value="" id="a1" />
</tr>
<tr>
<td colspan="2"><center><input type="submit" name="btnadd" /></center></td>
</tr>
</table>
</form>
session_start();
include("connection.php");
$error="";
?>
<?php if (isset($error)) { echo "<p class='message'>" .$error. "</p>" ;} ?>
<?php
ini_set("display_errors",0);
if(isset($_POST['btnadd']))
{
// $txtname=$_POST['txtname'];
$txtname=$_POST['txtname'];
$txtuname=$_POST['txtuname'];
$txtemail=$_POST['txtemail'];
$txtphonenum=$_POST['txtphonenum'];
$txtadd=$_POST['txtadd'];
$txtcode=$_POST['txtcode'];
$txtabout=$_POST['txtabout'];
$txtpass=$_POST['txtpass'];
$txtconpass=$_POST['txtconpass'];
$file=$_FILES['file']['name'];
$rand=rand(1,5000000);
$img=$rand.$file;
move_uploaded_file($_FILES['file']['tmp_name'],"imag/".$img);
$pass=$_POST['txtconpass'];
// $date = date('Y-m-d H:i:s');
$status='Active';
if($txtname == "")
{
// null chak name field
echo $error="Please Enter name";
$code="1";
}
elseif(!preg_match("/^[a-zA-Z]+$/",$txtname))
{
// chack name field only char
echo $first_nameErr = "Only letters allowed";
$code="1";
}
elseif($txtemail=="")
{
echo $error="Please Enter Email";
$code="2";
}
elseif(!preg_match("/^[_\.0-9a-zA-Z-]+@([0-9a-zA-Z][0-9a-zA-Z-]+\.)+[a-zA-Z]{2,6}$/i",$txtemail))
{
echo $error ="Please Enter valid Email";
$code="2";
}
elseif($txtphonenum=="")
{
echo $error= "Please Enter Mobile Number";
$code="3";
}
elseif(!preg_match("/^\d{10}$/",$txtphonenum))
{
echo $error = "Please Enter 10 Digit number";
$code= "3";
}
elseif(trim($txtadd)=="")
{
echo $error="Please Enter Your Address";
$code="4";
}
elseif(strlen($txtadd) < 60)
{
echo $error = "Please at least 60 word write";
$code = "4";
}
elseif($txtcode=="")
{
echo $error ="Please Enter Pincode ";
$code= "5";
}
elseif(!preg_match("/^\d{6}$/",$txtcode))
{
echo $error = "Enter must be 6 Digit";
$code = "5";
}
elseif(trim($txtabout)=="")
{
echo $error = "Please enter a About me";
$code="6";
}
elseif(strlen($txtabout) < 120)
{
echo $error = "Please at least 120 word write";
$code = "6";
}
elseif($txtpass=="")
{
echo $error= "Please Enter password";
$code = "7";
}
elseif(strlen($txtpass) < 8)
{
echo $error = "Please at lease 8 char length";
$code = "7";
}
elseif($txtconpass=="")
{
echo $error = "Please Enter confirm password";
$code= "8";
}
elseif($txtconpass !=$txtpass)
{
echo $error = "Your Password is not match";
$code = "8";
}
elseif(!preg_match("/[0-9a-zA-Z]/",$txtconpass))
{
echo $error= "Please Enter Char";
$code = "8";
}
elseif(!preg_match("/[@$,<>#:?_*&;]/",$txtconpass))
{
echo $error = "Pleace Enter at least one special char ";
$code = "8";
}
else
{
$sql="insert into reg(name,uname,uemail,phonenum,address,postcode,aboutme,pimage,pass,rdate,status) values('$txtname','$txtuname','$txtemail','$txtphonenum','$txtadd','$txtcode','$txtabout','$img','$txtconpass',now(),'$status')";
$sqlexcu=mysqli_query($dd,$sql);
echo "submit";
}
if(!$sqlexcu)
{
echo mysql_error();
}
else {
echo "<script>alert('Your Registration successfully');</script>";
}
}
?>
<style type="text/css" >
.error{border:1px solid red; }
.message{color: red; font-weight:italite;}
</style>
<form name="f2" id="f2" method="post" enctype="multipart/form-data" style=" margin-top: -100px;" onsubmit="return chkform(this);">
<table border="1">
<tr>
<th colspan="2">Registration Form</th>
</tr>
<tr>
<th>Name</th>
<td><input type="text" name="txtname" placeholder="Enter Name" value="<?php if(isset($txtname)) { echo $txtname; } ?>" <?php if(isset($code) && $code == 1){echo "class=error";} ?> /></td>
</tr>
<tr>
<th>User Name</th>
<td><input type="text" name="txtuname" placeholder="Enter User Name" onblur="userchaked(this.value)"/></td>
<span id="msg"></span>
</tr>
<tr>
<th>Email</th>
<td><input type="text" name="txtemail" placeholder="Enter email Addres" value="<?php if(isset($txtemail)) { echo $txtemail; } ?>" <?php if(isset($code) && $code == 2){echo "class=error";} ?> /> </td>
</tr>
<tr>
<th>Phone number</th>
<td><input type="text" name="txtphonenum" placeholder="Enter Phone number" value="<?php if(isset($txtphonenum)) { echo $txtphonenum; } ?>" <?php if(isset($code) && $code == 3) { echo "class=error"; } ?> /> </td>
</tr>
<tr>
<th>Address</th>
<td><textarea name="txtadd" <?php if(isset($code) && $code == 4) { echo "class=error"; } ?> > <?php if(isset($txtadd)) { echo $txtadd; } ?> </textarea></td>
</tr>
<tr>
<th>Post code</th>
<td><input type="text" name="txtcode" placeholder="Enter Postal Code" value="<?php if(isset($txtcode)) { echo $txtcode; } ?>" <?php if(isset($code) && $code == 5) { echo "class=error"; } ?> /></td>
</tr>
<tr>
<th>About Me</th>
<td><textarea name="txtabout" <?php if(isset($code) && $code == 6) { echo "class=error"; } ?> > <?php if(isset($txtabout)) { echo $txtabout; } ?> </textarea></td>
</tr>
<tr>
<th>Profile Image</th>
<td><input type="file" name="file" id="imgfile" onchange="readURL(this)";/></td>
<img id="preview" src="#" alt="." />
</tr>
<tr>
<th>Password</th>
<td><input type="password" name="txtpass" placeholder="Enter Password" value="<?php if(isset($txtpass)) { echo $txtpass; } ?>" <?php if(isset($code) && $code == 7) { echo "class=error"; } ?> /></td>
</tr>
<tr>
<th>Confirm Password</th>
<td><input type="password" name="txtconpass" placeholder="Enter Confirm password" value="<?php if(isset($txtconpass)) { echo $txtconpass; } ?>" <?php if(isset($code) && $code == 8) { echo "class=error"; } ?> /></td>
<input type="hidden" name="a1" value="" id="a1" />
</tr>
<tr>
<td colspan="2"><center><input type="submit" name="btnadd" /></center></td>
</tr>
</table>
</form>
No comments:
Post a Comment