Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- if(isset($_SESSION['id'])) {
- header("Location: user.php");
- }
- if(isset($_POST['register'])) {
- $db = mysqli_connect("localhost", "nunomarquina", "Amaral47",
- "proyecto_ets2mp");
- $username = strip_tags($_POST['username']);
- $password = strip_tags($_POST['password']);
- $password_confirm = strip_tags($_POST['password_confirm']);
- $mail = strip_tags($_POST['email']);
- $username = stripslashes($username);
- $password = stripslashes($password);
- $password_confirm = stripslashes($password_confirm);
- $mail = stripslashes($mail);
- $username = mysqli_real_escape_string($db, $username);
- $password = mysqli_real_escape_string($db, $password);
- $password_confirm = mysqli_real_escape_string($db, $password_confirm);
- $mail = mysqli_real_escape_string($db, $mail);
- $password = md5($password);
- $password_confirm = md5($password_confirm);
- $sql_store = "INSERT INTO users (username, password, email) VALUES ('$username', '$password', '$mail')";
- $sql_fetch_username = "SELECT username FROM users WHERE username = '$username'";
- $sql_fetch_mail = "SELECT email FROM users WHERE email = '$mail'";
- $query_username = mysqli_query($db, $sql_fetch_username);
- $query_mail = mysqli_query($db, $sql_fetch_mail);
- }
- ?>
- <!doctype html>
- <html>
- <head>
- <link rel="stylesheet" href="assets/css/main.css"/>
- <title>Register form</title>
- </head>
- <body>
- <div id="login">
- <h1>Register</h1>
- <form action="register.php" method="post" enctype="multipart/form-data">
- <input placeholder="Username" name="username" type="text">
- <input placeholder="Password" name="password" type="password">
- <input placeholder="Confirm Password" name="password_confirm" type="password">
- <input placeholder="E-Mail Adress" name="email" type="text">
- <input name="register" type="submit" value="Register">
- </form>
- <h2>Tienes una cuenta?</h2>
- <h2><a href="login.php">Inicia Sesion</a></h2>
- </div>
- </body>
- </html>
Add Comment
Please, Sign In to add comment