handle.php

mail@pastecode.io avatar
unknown
php
3 years ago
1.2 kB
8
Indexable
Never

if(isset($_POST['logon'])){
	
$nickname = filter_input(INPUT_POST, 'nickname', FILTER_SANITIZE_STRING);
$password = filter_input(INPUT_POST, 'password', FILTER_SANITIZE_STRING);   
	
$stmt = $campist->prepare('SELECT profileID,nickname,password FROM login WHERE nickname = ?');
$stmt->bind_param('s', $nickname,$password);
$stmt->execute();
$result = $stmt->get_result();
$row = $result->fetch_assoc();
	
if (password_verify($password, $row['password'])) {	

			$_SESSION['loggetindsom'] = $row['nickname'];
			$_SESSION['camLoginYes'] = 1;	
			if($_REQUEST['remember'] == 1) {
			$success_login = 1;
			setcookie ("nickname",$_POST["nickname"],time()+ (60*60*24*100));
			setcookie ("password",$_POST["password"],time()+ (60*60*24*100));
			setcookie ("remember",1,time()+ (60*60*24*100));
			} else {
			$success_login = 1;
			setcookie("nickname", "",time()- (60*60*24*100));			
			setcookie("password", "",time()- (60*60*24*100));	
			setcookie("remember", "",time()- (60*60*24*100));			
				}	
			$sendtoMyProfile = '/brugere/profil/'.$row['profileID'].'/';
            header("Location: ".$sendtoMyProfile."");
				}
				else 
				{
					$_SESSION['login-error'] = 1;
				}
	
}