Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- index.php
- ?php
- include_once 'header.php';
- ?>
- <section class="main-container">
- <div class="main-wrapper">
- <h2>Home</h2>
- </div>
- </section>
- <?php
- include_once 'footer.php';
- ?>
- header.php
- <!DOCTYPE html>
- <html>
- <head>
- <title></title>
- <link rel="stylesheet" type="text/css" href="style.css">
- </head>
- <body>
- <header>
- <nav>
- <div class="main-wrapper" >
- <ul>
- <li><a href="index.php">Home</a></li>
- </ul>
- <div class="nav-login">
- <form>
- <input type="text" name="uid" placeholder="Username/e-mail">
- <input type="password" name="pwd" placeholder="password">
- <button type="submit" name="submit">Login</button>
- </form>
- <a href="signup.php">Sign up</a>
- </div>
- </div>
- </nav>
- </header>
- footer.php
- </body>
- </html>
- signup.php
- <?php
- include_once 'header.php';
- ?>
- <section class="main-container">
- <div class="main-wrapper">
- <h2>Signup</h2>
- <form class="signup-form" action="includes/signup.inc.php" method="POST">
- <input type="text" name="first" placeholder="Firstname">
- <input type="text" name="last" placeholder="Lastname">
- <input type="text" name="email" placeholder="E-mail">
- <input type="text" name="uid" placeholder="Username">
- <input type="password" name="pwd" placeholder="Password">
- <button type="submit" name="submit">Sign up</button>
- </form>
- </div>
- </section>
- <?php
- include_once 'footer.php';
- ?>
- dbh.inc.php
- <?php
- $dbServername = "localhost";
- $dbUsername = "root";
- $dbPassword = "usbw";
- $dbName = "loginsystem";
- $conn = mysqli_connect($dbServername, $dbUsername, $dbPassword, $dbName );
- signup.inc.php
- <?php
- if (isset($_POST['submit'])) {
- include_once 'dbh.inc.php';
- $first = mysqli_real_escape_string($conn, $_POST['first']);
- $last = mysqli_real_escape_string($conn, $_POST['last']);
- $email = mysqli_real_escape_string($conn, $_POST['email']);
- $uid = mysqli_real_escape_string($conn, $_POST['uid']);
- $pwd = mysqli_real_escape_string($conn, $_POST['pwd']);
- //kijken of er niks leeg is
- if (empty($first) || empty($last) || empty($email) || empty($uid) || empty($pwd)) {
- header("Location: ../signup.php?signup=empty");
- exit();
- } else {
- // kijken of de input goed zijn
- if (!preg_match("/^[a-zA-Z]*$/", $first) || !preg_match("/^[a-zA-Z]*$/", $last) ) {
- header("Location: ../signup.php?signup=invalid");
- exit();
- } else {
- // kijken of het een email is @
- if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
- header("Location: ../signup.php?signup=email");
- exit();
- } else {
- $sql = "SELECT * FROM users WHERE user_uid='$uid'";
- $result = mysqli_query($conn, $sql);
- $resultCheck = mysqli_num_rows($result);
- if ($resultCheck > 0) {
- header("Location: ../signup.php?signup=usertaken");
- exit();
- } else {
- //hash de wachtwoord
- $hashedPwd = md5($pwd, PASSWORD_DEFAULT);
- //in de datebase stoppen
- $sql = "INSERT INTO users (user_first, user_last, user_email, user_uid user_pwd) VALUES ('$first', '$last', $email', '$uid', '$hashedPwd');";
- mysqli_query($conn, $sql);
- header("Location: ../signup.php?signup=succes");
- exit();
- }
- }
- }
- }
- } else {
- header("Location: ../signup.php");
- exit();
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement