Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- if(isset($_POST['submit'])){
- include 'connection.php';
- $firstname = $_POST['firstname'];
- $lastname = $_POST['lastname'];
- $username = $_POST['username'];
- $email = $_POST['email'];
- $password = $_POST['password'];
- $passwordconfirm = $_POST['passwordconfirm'];
- $gender = $_POST['reg_gender'];
- $agree = $_POST['agree'];
- $user = mysqli_query($conn, "SELECT username from users WHERE username = '".$username."'");
- $count = mysqli_num_rows($user);
- if($username =='' || $password =='' || $passwordconfirm =='' || $email =='' || $firstname =='' || $lastname =='' || $gender==''|| $agree =='' ){
- echo "Fill out the fields!";
- }
- else{
- if($password != $passwordconfirm){
- echo "Password does not match!";
- }
- else{
- if($count != 0){
- echo "Username already exists!";
- }
- else{
- $insert = mysqli_query($conn, "INSERT INTO users VALUES ('','$username','$password','$email','$firstname','$lastname','$gender','$agree')");
- if(!$insert){
- echo mysqli_errno();
- }
- else{
- echo "Records have been saved!";
- }
- }
- }
- }
- }
- ?>
- <html>
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <?php include('header.php'); ?>
- </head>
- <body>
- <?php include('navigation.php'); ?>
- <form method="POST" action="signup.php">
- <div id="loginsignup">
- <!-- LOGIN PAGE -->
- <!-- REGISTRATION FORM -->
- <div class="text-center" style="padding:50px 0">
- <div class="logo">register</div>
- <!-- Main Form -->
- <div class="login-form-1">
- <form id="register-form" class="text-left">
- <div class="login-form-main-message"></div>
- <div class="main-login-form">
- <div class="login-group">
- <div class="form-group">
- <label for="reg_username" class="sr-only">Username</label>
- <input type="text" class="form-control" id="reg_username" name="username" placeholder="Username">
- </div>
- <div class="form-group">
- <label for="reg_password" class="sr-only">Password</label>
- <input type="password" class="form-control" id="reg_password" name="password" placeholder="Password">
- </div>
- <div class="form-group">
- <label for="reg_password_confirm" class="sr-only">Password Confirm</label>
- <input type="password" class="form-control" id="reg_password_confirm" name="passwordconfirm" placeholder="Confirm Password">
- </div>
- <div class="form-group">
- <label for="reg_email" class="sr-only">Email</label>
- <input type="text" class="form-control" id="reg_email" name="email" placeholder="Email">
- </div>
- <div class="form-group">
- <label for="reg_firstname" class="sr-only">First Name</label>
- <input type="text" class="form-control" id="reg_firstname" name="firstname" placeholder="First Name">
- </div>
- <div class="form-group">
- <label for="reg_lastname" class="sr-only">Last Name</label>
- <input type="text" class="form-control" id="reg_lastname" name="lastname" placeholder="Last Name">
- </div>
- <div class="form-group login-group-checkbox">
- <input type="radio" class="" name="reg_gender" id="male" placeholder="username">
- <label for="male">Male</label>
- <input type="radio" class="" name="reg_gender" id="female" placeholder="username">
- <label for="female">Female</label>
- </div>
- <div class="form-group login-group-checkbox">
- <input type="checkbox" class="tickbox" id="reg_agree" name="agree" value="1"/>
- <label for="reg_agree">I agree with terms and conditions <a href="#">terms</a></label>
- </div>
- </div>
- <?php
- /* FIELDS ARE STILL EMPTY THIS CODE IS USED FOR HIDING PRECAUTIONAL PHP ERRORS MGS BECAUSE YOURE USING PHP AND HTML FORM IN 1 FILE*/
- require_once("connect.php");
- // Turn off error reporting
- error_reporting(0);
- // Report runtime errors
- error_reporting(E_ERROR | E_WARNING | E_PARSE);
- // Report all errors
- error_reporting(E_ALL);
- // Same as error_reporting(E_ALL);
- ini_set("error_reporting", E_ALL);
- // Report all errors except E_NOTICE
- error_reporting(E_ALL & ~E_NOTICE);
- /* FIELDS ARE STILL EMPTY THIS CODE IS USED FOR HIDING PRECAUTIONAL PHP ERRORS MGS BECAUSE YOURE USING PHP AND HTML FORM IN 1 FILE*/
- /* START */
- /* THIS LINE OF CODES , CHECKS WHETHER THERE IS CURRENTLY LOGGED IN USER AND WHETHER
- ITS AN ADMIN OR NON ADMIN*/
- if(isset($_SESSION['email'])){
- if($_SESSION['email']){
- $con = mysqli_connect("localhost", "root", "" ,"jono_db") or die("We couldn't connect!");
- $query = mysqli_query($con,"SELECT * FROM users WHERE email='".$_SESSION['email']."'");
- $numrows = mysqli_num_rows($query);
- if($numrows != 0){
- while($row = mysqli_fetch_assoc($query)){
- $usertype = $row['is_admin'];
- if($usertype == 1){
- echo'<label>User Type:</label><br/>';
- echo'<select name="usertype">';
- echo'<option value="1">ADMIN</option>';
- echo'<option value="0">NON ADMIN</option>';
- echo'</select>';
- }
- else{
- header('Location: home.php');
- }
- }
- }
- }
- }
- ?>
- <button type="submit" name="submit" class="login-button"><i class="fa fa-chevron-right"></i></button>
- </div>
- <div class="etc-login-form">
- <p>Already have an account? <a href="auth.php">Login Here</a></p>
- </div>
- </form>
- </div>
- <!-- end:Main Form -->
- </div>
- </div>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement