SHOW:
|
|
- or go back to the newest paste.
1 | index.php | |
2 | - | Всего: <?php echo (isset($_SESSION['amount']) ? $_SESSION['amount'] : 0); ?> |
2 | + | |
3 | Всего: <?php session_start(); echo (isset($_SESSION['amount']) ? $_SESSION['amount'] : 0); ?> | |
4 | <hr /> | |
5 | <button onclick="location.href='add.php?amount=15'">добавить 15</button> | |
6 | <button onclick="location.href='add.php?amount=50'">добавить 50</button> | |
7 | ================================================================ | |
8 | - | if (isset($_GET['amount'])) { |
8 | + | |
9 | ________________________________________________________________ | |
10 | <?php | |
11 | if (isset($_GET['amount']) && ctype_digit($_GET['amount'])) { | |
12 | session_start(); | |
13 | $_SESSION['amount'] += (int) $_GET['amount']; | |
14 | } else { | |
15 | die('Нужно передать значение'); | |
16 | } | |
17 | Header('Location: index.php'); | |
18 | ?> |