Reputation: 11
session_start();
if(!isset($_SESSION['wylosowana'])) {
$_SESSION['wylosowana'] = rand(1,100);
}
if(isset($_POST['liczba'])) {
if(!isset($_SESSION['proba'])) {
$_SESSION['proba'] = 1;
}
if($_POST['liczba']<$_SESSION['wylosowana']) {
$_SESSION['blad'] = "Wprowadzona liczba jest za mała";
if(isset($_SESSION['proba'])) {
$_SESSION['proba']=+1;
}
} else if ($_POST['liczba']>$_SESSION['wylosowana']) {
$_SESSION['blad'] = "Wprowadzona liczba jest za duża";
if(isset($_SESSION['proba'])) {
$_SESSION['proba']=+1;
}
} else {
$_SESSION['zgadles']=true;
$_SESSION['blad'] = "Wygrałeś za ".$_SESSION['proba']." razem";
}
}
$_SESSION['proba']
always is equal to 1. To be honest i dont know where is the problem. I tried few methods but it still not working. Please tell me where is the problem. Thanks.
Upvotes: 1
Views: 48
Reputation: 289
Your code : $_SESSION['proba']=+1;
Use instead $_SESSION['proba'] += 1;
or $_SESSION['proba'] = $_SESSION['proba'] + 1;
Upvotes: 1