Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- session_start();
- require_once '../connect/db.php';
- if ($loggedin) {
- header("Location: index.php");
- exit;
- }
- if (isset($_POST['sign_up'])) {
- $username = strip_tags($_POST['username']);
- $email = strip_tags($_POST['email']);
- $description = mysqli_real_escape_string(strip_tags(stripslashes($conn, $_POST['desc'])));
- $password = strip_tags($_POST['password']);
- $conPassword = $_POST['conPass'];
- $passHash = password_hash($password, PASSWORD_BCRYPT);
- if ($password !== $conPassword) {
- $msg = "Your passwords do not match!";
- }
- $usercheck = $con->query("SELECT username FROM users WHERE username='$username'");
- if ($usercheck->num_rows > 0) {
- $msg = "Username is taken.";
- }
- $emailcheck = $con->query("SELECT email FROM users WHERE email='$email'");
- if ($emailcheck->num_rows > 0) {
- $msg = "Email is taken.";
- }
- if(strlen($username) < 3 || strlen($username) > 32) {
- $msg = "<b>Warning:</b> Username must be 3-32 characters long.";
- }
- if(strlen($password) < 6 || strlen($password) > 60) {
- $msg = "<b>Warning:</b> Password must be 6-60 characters long.";
- }
- if(empty($msg)) {
- $query = "INSERT INTO users(username,email,password,description) VALUES('$username','$email','$passHash','$description')";
- if ($con->query($query)) {
- $msg = "<b>Success:</b> You have signed up please Signin!";
- }else{
- $msg = "<b>Error:</b> Something went wrong, Please try again!";
- }
- }
- }
- ?>
- <html>
- <head>
- <title>Signup | Veneria</title>
- <meta charset="UTF-8">
- <meta name="viewport" content="width=device-width, initial-scale=1.0, shrink-to-fit=no">
- <link rel="stylesheet" type="text/css" href="../style.css">
- <link rel="icon" href="/images/logos/favicon.png">
- </head>
- <body>
- <center><img src="../images/logo.png" class="veneria"></center>
- <div id="navigation">
- <div id="header">
- <?php
- include '../navbar.php';
- include '../removebanner.php';
- ?>
- </div>
- </div>
- <div id="container">
- <div id="header">
- <center><h1>Signup!</h1></center>
- <?php
- if (isset($msg)) {
- echo $msg;
- }
- ?>
- </div>
- <div id="content">
- <form method="POST" action="">
- <input type="text" style="width: 25%" placeholder="Username" name="username">
- <input type="text" style="width: 25%;" placeholder="Email" name="email">
- <input type="text" style="width: 25%;" Placeholder="Description" name="desc">
- <input type="password" style="width: 25%;" placeholder="Password" name="password">
- <input type="password" style="width: 25%;" Placeholder="Confirm Password" name="conPass">
- <input type="submit" class="btn green" value="Sign Up" name="sign_up">
- </form>
- </div>
- </div>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement