Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- ob_start();
- include 'inc/database.php';
- include "captcha/simple-php-captcha.php";
- if (!isset($_SESSION)) {
- session_start();
- }
- if (!isset($_SESSION['captcha'])) {
- $_SESSION['captcha'] = simple_php_captcha();
- }
- if (isset($_SESSION['username'])) {
- header('Location: index.php');
- exit();
- }
- if(isset($_POST['username']) && isset($_POST['password']) && isset($_POST['confirmpassword']) && isset($_POST['email']) && isset($_POST['CaptchaClick'])) {
- $username = mysqli_real_escape_string($con, $_POST['username']);
- $password = mysqli_real_escape_string($con, md5($_POST['password']));
- $confirmpassword = mysqli_real_escape_string($con, md5($_POST['confirmpassword']));
- $email = mysqli_real_escape_string($con, $_POST['email']);
- $enteredCaptcha = $_POST['CaptchaClick'];
- if($enteredCaptcha != $_SESSION['captcha']['code']){
- session_destroy();
- die("Captcha is wrong.");
- header("Location: register.php?error=captcha");
- }
- if($password != $confirmpassword){
- session_destroy();
- die("The confirmation password was not equal to the password.");
- header("Location: register.php?error=captcha");
- }
- if(!filter_var($email, FILTER_VALIDATE_EMAIL)) {
- session_destroy();
- die("The email entered was not correct.");
- header("Location: register.php?error=captcha");
- }
- $result = mysqli_query($con, "SELECT * FROM `users` WHERE `username` = '$username'") or die(mysqli_error($con));
- if(mysqli_num_rows($result) > 0){
- die("This username already exists.");
- }
- $result = mysqli_query($con, "SELECT * FROM `users` WHERE `email` = '$email'") or die(mysqli_error($con));
- if(mysqli_num_rows($result) > 0){
- die("This email already exists.");
- }
- $ip = mysqli_real_escape_string($con, $_SERVER['HTTP_CF_CONNECTING_IP']);
- $date = date('Y-m-d');
- mysqli_query($con, "INSERT INTO `users` (`username`, `password`, `email`, `date`, `ip`) VALUES ('$username', '$password', '$email', '$date', '$ip')") or die(mysqli_error($con));
- header("Location: login.php?action=registered");
- }
- ?>
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="utf-8" />
- <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no" />
- <link rel="stylesheet" href="/assets/css/bg.css" />
- <noscript><link rel="stylesheet" href="assets/css/noscript.css" /></noscript>
- <title>Oculous - Registration</title>
- <link href="css/bootstrap-reset.css" rel="stylesheet">
- <link href="assets/font-awesome/css/font-awesome.css" rel="stylesheet" />
- <body style="height:100%; width:100%;" class="login-body">
- <center>
- <form style="height:50%; width:50%;" class="form-signin" action="register.php" method="POST">
- <br>
- <br>
- <h1 class="form-signin-heading">Register</h1>
- <div class="login-wrap">
- <br>
- <input type="text" id="username" name="username" class="form-control" placeholder="Username" autofocus>
- <br>
- <input type="password" id="password" name="password" class="form-control" placeholder="Password">
- <br>
- <input type="password" id="confirmpassword" name="confirmpassword" class="form-control" placeholder="Confirm Password">
- <br>
- <input type="text" id="email" name="email" class="form-control" placeholder="Email">
- <br>
- <?php
- echo '<img src="' . $_SESSION['captcha']['image_src'] . '" alt="CAPTCHA code">';
- ?>
- <br>
- <input name="CaptchaClick" id="CaptchaClick" cols="5" type="text" placeholder="Enter Captcha...">
- <br>
- <p style="height:100%; width:100%;"> By clicking the Sign up button you are agreeing to the <a href="ToS.php"> <font color="grey"> Terms of service </font> </p> </a>
- <button style="height:90%; width:90%;" class="btn btn-lg btn-login btn-block" type="submit">Sign up</button>
- </form>
- <br> <br>
- <div class="registration"> <font color="grey">
- Already have an account?  </font>
- <a class="" href="login.php">
- Sign In
- </a>
- </div>
- <script src="js/jquery.js"></script>
- <script src="js/bootstrap.min.js"></script>
- <footer id="footer">
- <p class="copyright">© Oculous Development</a>.</p>
- </footer>
- </center>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement