Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- function Login() {
- $success = false;
- $usr = "XXX";
- $psw = "XXX";
- alert("HELLOOOOO");
- try {
- $con = new PDO( 'mysql:host=localhost;dbname=exalumnes', $usr, $psw );
- $sql = "SELECT * FROM Usuaris WHERE NomUsuari = :username AND Password = :password LIMIT 1";
- //users //username
- alert($sql);
- $stmt = $con->prepare( $sql );
- $stmt->execute(array(':username'=>$_POST['username'], ':password'=>$_POST['password']));
- $valid = $stmt->fetchColumn();
- if( $valid ) {
- $success = true;
- session_start();
- session_regenerate_id();
- $_SESSION['user'] = $_POST['username'];
- session_write_close();
- echo ('CORRECTO');
- exit();
- }
- $con = null;
- return $success;
- }
- catch (PDOException $e) {
- echo $e->getMessage();
- return $success;
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement