Guest User

laddu

a guest
Aug 19th, 2017
23
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.55 KB | None | 0 0
  1. <html>  
  2. <head lang="en">  
  3.     <meta charset="UTF-8">  
  4.     <link type="text/css" rel="stylesheet" href="bootstrap-3.2.0-dist\css\bootstrap.css">  
  5.     <title>Registration</title>  
  6. </head>  
  7. <style>  
  8.     .login-panel {  
  9.         margin-top: 150px;  
  10.  
  11. </style>  
  12. <body>  
  13.  
  14. <div class="container"><!-- container class is used to centered  the body of the browser with some decent width-->  
  15.     <div class="row"><!-- row class is used for grid system in Bootstrap-->  
  16.         <div class="col-md-4 col-md-offset-4"><!--col-md-4 is used to create the no of colums in the grid also use for medimum and large devices-->  
  17.             <div class="login-panel panel panel-success">  
  18.                 <div class="panel-heading">  
  19.                     <h3 class="panel-title">Registration</h3>  
  20.                 </div>  
  21.                 <div class="panel-body">  
  22.                     <form role="form" method="post" action="registration.php">  
  23.                         <fieldset>  
  24.                             <div class="form-group">  
  25.                                 <input class="form-control" placeholder="Username" name="name" type="text" autofocus>  
  26.                             </div>  
  27.  
  28.                             <div class="form-group">  
  29.                                 <input class="form-control" placeholder="E-mail" name="email" type="email" autofocus>  
  30.                             </div>  
  31.                             <div class="form-group">  
  32.                                 <input class="form-control" placeholder="Password" name="pass" type="password" value="">  
  33.                             </div>  
  34.  
  35.  
  36.                             <input class="btn btn-lg btn-success btn-block" type="submit" value="register" name="register" >  
  37.  
  38.                         </fieldset>  
  39.                     </form>  
  40.                     <center><b>Already registered ?</b> <br></b><a href="login.php">Login here</a></center><!--for centered text-->  
  41.                 </div>  
  42.             </div>  
  43.         </div>  
  44.     </div>  
  45. </div>  
  46.  
  47. </body>  
  48.  
  49. </html>  
  50.  
  51. <?php  
  52.  
  53. include("database/db_conection.php");//make connection here  
  54. if(isset($_POST['register']))  
  55. {  
  56.     $user_name=$_POST['name'];//here getting result from the post array after submitting the form.  
  57.     $user_pass=$_POST['pass'];//same  
  58.     $user_email=$_POST['email'];//same  
  59.  
  60.  
  61.     if($user_name=='')  
  62.     {  
  63.         //javascript use for input checking  
  64.         echo"<script>alert('Please enter the name')</script>";  
  65. exit();//this use if first is not work then other will not show  
  66.     }  
  67.  
  68.     if($user_pass=='')  
  69.     {  
  70.         echo"<script>alert('Please enter the password')</script>";  
  71. exit();  
  72.     }  
  73.  
  74.     if($user_email=='')  
  75.     {  
  76.         echo"<script>alert('Please enter the email')</script>";  
  77.     exit();  
  78.     }  
  79. //here query check weather if user already registered so can't register again.  
  80.     $check_email_query="select * from users WHERE user_email='$user_email'";  
  81.     $run_query=mysqli_query($dbcon,$check_email_query);  
  82.  
  83.     if(mysqli_num_rows($run_query)>0)  
  84.     {  
  85. echo "<script>alert('Email $user_email is already exist in our database, Please try another one!')</script>";  
  86. exit();  
  87.     }  
  88. //insert the user into the database.  
  89.     $insert_user="insert into users (user_name,user_pass,user_email) VALUE ('$user_name','$user_pass','$user_email')";  
  90.     if(mysqli_query($dbcon,$insert_user))  
  91.     {  
  92.         echo"<script>window.open('welcome.php','_self')</script>";  
  93.     }  
  94.  
  95.  
  96.  
  97. }  
  98.    ?>
Add Comment
Please, Sign In to add comment