Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions General Analysis/phpinfo.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php

#See the PHP configuration

phpinfo();


?>
9 changes: 9 additions & 0 deletions General Analysis/server_variables.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

#Analysis of the local PHP server variable $_SERVER

echo '<pre>';
print_r($_SERVER);


?>
18 changes: 18 additions & 0 deletions General Analysis/session_variables.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

#Analysis of the local PHP server variable $_SESSION

session_start();

$_SESSION['browser'] = $_SERVER['HTTP_USER_AGENT'];
$_SESSION['ip'] = $_SERVER['REMOTE_ADDR'];
$_SESSION['TIME'] = time();

echo '<pre>';
print_r($_SESSION);
echo '</pre>';




?>
8 changes: 8 additions & 0 deletions Session login Exercise/close_session.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php
session_start();

session_destroy();

header("Location: ./index.php");

?>
36 changes: 36 additions & 0 deletions Session login Exercise/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-rbsA2VBKQhggwzxH7pPCaAqO46MgnOM80zW1RWuH61DGLwZJEdK2Kadq2F9CUG65" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.11.6/dist/umd/popper.min.js" integrity="sha384-oBqDVmMz9ATKxIep9tiCxS/Z9fNfEXiDAYTujMAeBAsjFuCZSmKbSSUnQlmh/jp3" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/js/bootstrap.min.js" integrity="sha384-cuYeSxntonz0PPNlHhBs68uyIAVpIIOZZ5JqeqvYYIcEL727kskC66kF92t6Xl2V" crossorigin="anonymous"></script>
<title>Document</title>
</head>

<?php

if(isset($_GET["error"])) echo "<b>You must log in!</b>";
if(isset($_GET["logout"])) echo "<b>You are log out!</b>";

?>

<body class="text-center">
<main class="form-signin m-auto">
<form action = "validate.php" method="POST">
<div class="m-3">
<label for="user" class="form-label">Name</label>
<input name= "user" type="text" class="form-control" required>
<div class="form-text">Write your username</div>
</div>
<div class="m-3">
<label for="password" class="form-label">Password</label>
<input name= "password" type="password" class="form-control" required>
</div>
<button type="submit" class="btn btn-primary">Log in</button>
</form>
</main>
</body>
</html>
34 changes: 34 additions & 0 deletions Session login Exercise/panel.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php
session_start();

?>

<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-rbsA2VBKQhggwzxH7pPCaAqO46MgnOM80zW1RWuH61DGLwZJEdK2Kadq2F9CUG65" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.11.6/dist/umd/popper.min.js" integrity="sha384-oBqDVmMz9ATKxIep9tiCxS/Z9fNfEXiDAYTujMAeBAsjFuCZSmKbSSUnQlmh/jp3" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/js/bootstrap.min.js" integrity="sha384-cuYeSxntonz0PPNlHhBs68uyIAVpIIOZZ5JqeqvYYIcEL727kskC66kF92t6Xl2V" crossorigin="anonymous"></script>
<title>Private Panel</title>
</head>

<body>
<h1>Private Panel</h1>

<?php

if (isset($_SESSION["user"])) {
echo "Welcome, " . $_SESSION["user"], "<br>";
} else {
header("Location: ./index.php");
}
?>

<button><a href="close_session.php" class="btn btn-primary">Log out</a></button>
</body>

</html>
22 changes: 22 additions & 0 deletions Session login Exercise/validate.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

session_start();

print_r($_REQUEST);



$name = "monica";
$password = "1234";


if($_REQUEST['user'] == $name && $_REQUEST['password'] == $password){
$_SESSION['user'] = $_REQUEST['user'];
header("Location: panel.php");
}else{
header("Location: index.php?error=incorrectuser");
}



?>