<?php 
@header('Content-type: text/html;charset=utf-8');
session_start();
require_once('view_users.php');
//echo $user_id;
?>
<html>  
<head lang="en">  
    <meta charset="UTF-8">  
    <link type="text/css" rel="stylesheet" href="bootstrap-3.2.0-dist\css\bootstrap.css">  
    <title>Registration</title>  
</head>  
<style>  
    .login-panel {  
        margin-top: 150px;  
  
</style>  
<body>  
  
<div class="container"><!-- container class is used to centered  the body of the browser with some decent width-->  
    <div class="row"><!-- row class is used for grid system in Bootstrap-->  
        <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-->  
            <div class="login-panel panel panel-success">  
                <div class="panel-heading">  
                    <h3 class="panel-title">Registration</h3>  
                </div>  
                <div class="panel-body">  
                    <form role="form" method="post" action="registration3.php">  
                        <fieldset>  
  
                   <div class="form-group">  
                                <input class="form-control" placeholder="hashh" name="hashh" type="text" autofocus>  
                            </div>
                    
                            <input class="btn btn-lg btn-success btn-block" type="submit" value="register" name="register" >  
  
                        </fieldset>  
                    </form>  
                    <center><b>Already registered ?</b> <br></b><a href="login.php">Login here</a></center><!--for centered text-->  
                </div>  
            </div>  
        </div>  
    </div>  
</div>  
  
</body>  
  
</html>  
  
<?php  
  
include("database/db_conection.php");//make connection here  
if(isset($_POST['register']))  
{  
    $user_name=$_POST['name'];//here getting result from the post array after submitting the form.  
    $user_pass=$_POST['pass'];//same  
    $user_email=$_POST['email'];//same  
   $hashh=$_POST['hashh'];
//here query check weather if user already registered so can't register again.  
    $check_email_query="select * from users WHERE hash='$hashh'";  
    $run_query=mysqli_query($dbcon,$check_email_query);  
  
    if(mysqli_num_rows($run_query)>0)  
    {  
   $Upda_news = "UPDATE users SET groub_id='1' where user_id='$user_id'";
       $Upda_news=mysqli_query($dbcon,$Upda_news);  
/*echo "<script>alert('Email $user_email is already exist in our database, Please try another one!')</script>";  */
exit();  
    }  
//insert the user into the database.  
    /*$insert_user="insert into users (user_name,user_pass,user_email) VALUE ('$user_name','$user_pass','$user_email')"; */
    /*if(mysqli_query($dbcon,$Upda_news))  
    {  
        echo"<script>window.open('welcome.php','_self')</script>";  
    }  */
}
?> 
<?php 
echo  $names;?>
