odsyłanie po logowaniu do posta

This commit is contained in:
s416267 2018-12-16 20:04:16 +01:00
parent 60a0fe182d
commit 0fc2b9a2a4
2 changed files with 18 additions and 2 deletions

View File

@ -1,4 +1,11 @@
<?php include "logincheck.php"; ?>
<?php
include "logincheck.php";
if(isset($_GET['post'])) {
if( !isset( $_SESSION ) ) session_start();
$_SESSION['post'] = $_GET['post'];
}
?>
<html>
<head>
<title>Logowanie - Projekt blogowy</title>
@ -48,6 +55,9 @@
<span class="checkmark"></span>
</label>
</div>
<div class="form-group toregister">
<a href="../register">Nie mam konta</a>
</div>
</div>
</div>
<div class="row loginFooter">

View File

@ -12,10 +12,16 @@ if(isset($_POST['submitas'])){
$query = mysqli_query($mysqli, "SELECT * FROM user WHERE password='$password' AND username='$user'");
$rows = mysqli_num_rows($query);
if($rows == 1){
header("Location: index.php");
$_SESSION['user']=$user;
$_SESSION['password']=$password;
$_SESSION['loggedIn']=1;
if (isset($_SESSION['post'])) {
$post = $_SESSION['post'];
header("Location: ../blog-post/post.php?post=$post");
}
else {
header("Location: index.php");
}
}
else{
$error="Login lub hasło są nieprawidłowe!";