Show sourcecode
The following files exists in this folder. Click to view.
webbserverprogrammering/exercises/cookie-session/
cookie-session1.php
cookie-session2.php
cookie-session3.php
cookie-session4.php
cookie-session5.php
hemlig.php
cookie-session4.php
33 lines ASCII Windows (CRLF)
<?php
session_start();
?>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>session4</title>
</head>
<body>
<form method="post" action="">
<input type="text" name="tal">
<input type="submit" name="">
</form>
<?php
if (isset($_POST["tal"]) && $_POST["tal"] != "") {
$medel=0;
array_push($_SESSION["tal"], $_POST["tal"]);
for ($i=0; $i < count($_SESSION["tal"]); $i++) {
echo($_SESSION["tal"][$i]."<br>");
$medel+=$_SESSION["tal"][$i];
}
$medel/=count($_SESSION["tal"]);
echo "<strong>".$medel."</strong>";
}
else{
$_SESSION["tal"] = array();
}
?>
</body>
</html>