PHPize Online / SQLize Online  /  SQLtest Online

A A A
Share      Blog   Popular
Copy Format Clear
Copy Clear
Copy Format Clear
<?php session_start(); if (!isset($_SESSION['user'])) { $_SESSION['user'] = 10; } if (!isset($_SESSION['bot'])) { $_SESSION['bot'] = 10; } if($_POST['submit']) { if($_POST['number']==rand(1,3)){ $_SESSION['user']-=rand(1,4); } if($_POST['name']!=rand(1,3)){ $_SESSION['bot']-=rand(1,4); } if ($_SESSION['user'] == 0 && $_SESSION['bot'] == 0) { echo 'Ничья'; $_SESSION = []; } else { if ($_SESSION['user'] == 0) { echo 'бот победил'; $_SESSION = []; } if ($_SESSION['bot'] == 0) { echo 'бот проиграл'; $_SESSION = []; } } } echo $_SESSION['user']." user"."<br>"; echo $_SESSION['bot']." bot"; // Проверка условия победы или поражения if ($_SESSION['player_hp'] <= 0) { header('Location: gameover.php?result=loss'); exit(); } elseif ($_SESSION['server_hp'] <= 0) { header('Location: gameover.php?result=win'); exit(); } session_start(); $result = $_GET['result']; if ($result == 'win') { echo 'Вы победили!'; } elseif ($result == 'loss') { echo 'Вы проиграли!'; }
Show:  
Copy Clear