Hi,
to my understanding, isset()
checks is the variable exist and have a value. But when I try the code below, _randNum() keeps on getting new values when it should already have a value because it already exist and have a value.
<?php
session_start();
if(!isset($_randNum)){ //Check if the variable dont exist
$_randNum = rand (10, 20); //if not
}
$rNum = $_randNum;
?>
I have a form to check the value in $rNUm
:
<form method="post" action="guessinggame.php">
<p><input type="text" name="tb" id="tb" />
<input type="submit" name="guess" id="guess" value="Guess" /></p>
</form>
<?php
echo "$rNum";
?>
This is my first php so i'm not really sure whats going on.