Guest User

Untitled

a guest
Jun 3rd, 2014
822
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. index.php
  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. add.php
  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. ?>
RAW Paste Data