Joc - Dat cu zarul
Scris: Mie Oct 26, 2011
va rog daca ma outeti ajuta cu acest joculet...de ce nu functioneaza?
index.php
cazinou.php
ar trebui sa arunce cu zaru..daca e mai mare a meu decat al adeversarului sa cresaca banii cu o unitate daca nu contrariul???
multumesc mult
index.php
Cod: Selectaţi tot
<?php
session_start();
if(!isset($_SESSION['bani'])){
$_SESSION['bani']=10;}
if(!isset($_SESSION['zar'])){
$_SESSION['zar']=rand(0,10);}
if(!isset($_SESSION['zara'])){
$_SESSION['zara']=rand(0,10);}
echo '<b>Banii tai sunt:';
echo $_SESSION['bani'];
echo '<br><br><a href="cazinou.php">Cazinou</a>';
?>
Cod: Selectaţi tot
<?php
session_start();
echo '<h2>Welcome</h2>';
echo 'Vrei sa joci?';
echo '<br>';
echo '<form method=post action=" " >
<input type=submit name=submit value=da></form>';
echo '<br>';
if(isset($_POST['submit'])){
echo 'Banii tai:';
echo $_SESSION['bani'];
echo '<form method=post action=" " >
<input type=submit name=da value=arunca cu zaru></form>';
echo '<br>';
if(isset($_POST['da'])){
echo 'ai dat cu zarul:';
echo $_SESSION['zar'];
echo 'adversarul tau a dat:';
echo $_SESSION['zara'];
if($_SESSION['zar']>$_SESSION['zara']) { echo 'ai castigat'; echo $_SESSION['bani']++;
$_SESSION['zar']=" ";
$_SESSION['zara']=" ";
} else { echo 'ai pierdut';
echo $_SESSION['bani']--;
$_SESSION['zar']=" ";
$_SESSION['zara']=" ";
}
}
}
?>
multumesc mult