Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- require_once 'Classes/ClassUser.php';
- require_once 'DBconnect.php';
- if ($_SERVER['REQUEST_METHOD'] === 'POST') {
- if (isset($_POST['email']) && isset($_POST['password']) && isset($_POST['username'])) {
- $mail = $_POST['email'];
- $pas = $_POST['password'];
- $uName = $_POST['username'];
- $user = new User();
- $user->setEmail($mail);
- $user->setUsername($uName);
- $user->setHashPass($pas);
- $a = $user->saveToDB($conn);
- session_start();
- $sql = "SELECT id FROM users WHERE email ='$mail' and hash_pass = '$pas'";
- $result = $conn->query($sql);
- var_dump($result);
- // $row = mysqli_fetch_array($result,MYSQLI_ASSOC);
- $row = $result->fetch(PDO::FETCH_ASSOC);
- var_dump($row);
- $count = count($result);
- var_dump($count);
- // If result matched $myusername and $mypassword, table row must be 1 row
- if($count == 1 && $row != false) {
- $_SESSION['login_userId'] = $row['id'];
- header("location: HomePage.php");
- }else {
- $error = "Your Login Name or Password is invalid";
- echo $error;
- }
- }
- }
- ?>
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <title>Title</title>
- </head>
- <body>
- <h2>Rejestracja</h2>
- <form action="" method="post">
- Podaj nazwę użytkownika :
- <input type="text" name="username"> </input>
- Podaj adres email :
- <input type="text" name="email"> </input>
- Podaj hasło :
- <input type="text" name="password"> </input>
- <button type="submit">Zarejestruj się</button>
- </form>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement