I want it to increment and decrement the value in $_SESSION['selection'].
Mousedown on next form results in: "The session is 1".
Mousedown on previous form results in "The session is -1".
İşte kod:
<?php
if (isset($_POST['next'])) {
displaynext();
}
else if (isset($_POST['previous'])) {
displayprevious();
}
else {
session_start();
echo "session started";
$_SESSION['selection'] = 1;
}
function displaynext() {
$_SESSION['selection'] = $_SESSION['selection'] + 1;
echo "The session is $_SESSION[selection]";
}
function displayprevious() {
if ($_SESSION['selection'] != 1) {
$_SESSION['selection'] = $_SESSION['selection'] - 1;
}
echo "The session is $_SESSION[selection]";
}
?>
<form action="<?=$_SERVER['PHP_SELF'];?>" method="post">
<input type="submit" name="previous" value="Previous">
</form>
<form action="<?=$_SERVER['PHP_SELF'];?>" method="post">
<input type="submit" name="next" value="Next">
</form>