Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Inserisco i dati nel DB
- $nome = $_GET['nome'];
- $cognome = $_GET['cognome'];
- $email = $_GET['email'];
- $username = $_GET['username'];
- $password = $_GET['password'];
- $hash = password_hash($password, PASSWORD_BCRYPT);
- $sql = "INSERT INTO clienti (nome, cognome, email, username, password)
- VALUES (:nome, :cognome, :email, :username, :password)";
- $req = $dbh->prepare($sql);
- $req->execute(
- array(
- ":nome" => $nome,
- ":cognome" => $cognome,
- ":email" => $email,
- ":username" => $username,
- ":password" => $hash,
- )
- );
- //login
- require_once 'includes/connect-db.php';
- session_start();
- $_SESSION['loggato'] = false;
- $username = $_REQUEST['username'];
- $password = $_REQUEST['password'];
- $sql = "SELECT * FROM clienti WHERE username = :username AND password = :password";
- $req = $dbh->prepare($sql);
- $req->execute(
- array(
- ":username" => $_REQUEST['username'],
- ":password" => $_REQUEST['password']
- )
- );
- $utente = $req->fetch(PDO::FETCH_ASSOC);
- if($utente != null) {
- $_SESSION['loggato'] = true;
- $_SESSION['utente'] = $utente;
- Header('Location: index.php');
- } else {
- Header('Location: login.php?error=true');
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement