Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE HTML>
- <html>
- <?php
- session_start();
- include_once "header.php"
- ?>
- <head>
- <link href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet">
- <link href="/css/index.css" rel="stylesheet">
- <meta charset="UTF-8">
- <title><?php echo htmlspecialchars($site_name); echo " – Register"; ?></title>
- </head>
- <body style="background-color:#111111;">
- <?php
- function addUser($username, $password, $email, $connn){
- $password_safe = password_hash($password, PASSWORD_BCRYPT);
- $sql = "INSERT INTO user (username, password, email) VALUES ('$username', '$password_safe', '$email')";
- $result = mysqli_query($connn, $sql);
- echo($conn);
- }
- $username = $_POST["username"];
- $password = $_POST["password"];
- $password2 = $_POST["passwordagain"];
- $email = $_POST["email"];
- $success = array(
- "success" => True,
- "username" => True,
- "password" => True,
- "passwordagain" => True,
- "email" => True,
- "exists" => True,
- "exists_username" => True,
- "exists_email" => True,
- );
- if(isset($_POST["username"], $_POST["password"], $_POST["passwordagain"], $_POST["email"])){
- if(strlen($username) < 4){
- $success["username"] = False;
- $success["success"] = False;
- }else if(strlen($password) < 8){
- $success["password"] = False;
- $success["success"] = False;
- }else if(!preg_match('/[A-Za-z].*[0-9]|[0-9].*[A-Za-z]/', $password)){
- $success["password"] = False;
- $success["success"] = False;
- }else if(!strpos($email, "@") || !strpos($email, ".")){
- $success["email"] = False;
- $success["success"] = False;
- }else if($password != $password2){
- $sucess["passwordagain"] = False;
- $success["success"] = False;
- }
- if($success["success"] == True){
- $username_safe = mysqli_real_escape_string($conn, $username);
- $password_safe = mysqli_real_escape_string($conn, $password2);
- $email_safe = mysqli_real_escape_string($conn, $email);
- $sql_un = "SELECT $username_safe FROM user";
- $result_un = mysqli_query($conn, $sql_un);
- if ($result_un->num_rows > 0) {
- $success["exists"] = False;
- $success["success"] = False;
- } else {
- $sql_mail = "SELECT $email_safe FROM user";
- $result_mail = mysqli_query($conn, $sql_mail);
- if ($result_mail->num_rows > 0) {
- $success["exists"] = False;
- $success["success"] = False;
- } else {
- //Finally register user
- addUser($username_safe, $password_safe, $email_safe, $conn);
- }
- }
- }else{
- //TO-DO///////////LVL3///////////Redirect user back to register page with information about failure
- }
- }else{
- //TO-DO///////////LVL3///////////Redirect user back to register page with information about failure
- }
- ?>
- <div align="center">
- <font color="white"><p tkey="registerheader"></p></font>
- <form action="/register.php" method="post">
- <span><font color="white"><a tkey="registername"></a>: <input type="text" name="username" placeholder="Username"></font></span>
- <br>
- <span><font color="white"><a tkey="registerpassword"></a>: <input type="password" name="password" placeholder="Password"></font></span>
- <br>
- <span><font color="white"><a tkey="registerpasswordagain"></a>: <input type="password" name="passwordagain" placeholder="Password Again"></font></span>
- <br>
- <span><font color="white"><a tkey="registermail"></a>: <input type="text" name="email" placeholder="A-mail adress"></font></span>
- <br>
- <i><font color="white"><a class="nodeco" href="http://teez0sproject.my-style.in/login" tkey="login"></a></font></i><br>
- <input type="submit" tkey="loginsend" class="btn">
- </form>
- </div>
- <script src="http://code.jquery.com/jquery-1.11.0.min.js"></script>
- <script src="js/lang.js"></script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement