Hi, i am having trouble in understanding how session works. I am trying to write a program that will repeatedly request a number to be entered and each time the number is entered the program is to print out:
- that number
- the sum of all the numbers entered
- the count in how many times I submitted
This is my code so far:
<?php
session_start();
if(isset($_session['count']))
{
$_session['count'] = $count;
}else{
$_session['count'] = 0;
}
?>
<html>
<head>
<title>number</Title>
<style>
</style>
<body>
<form action = "numbers.php" method = "post">
Numbers: <input type "text" name = "number" size = "6"/>
<input type = "submit" value = "submit" name = "submit"/>
<p>
</form>
</body>
</head>
</Html>
<?php
if(isset($_POST["submit"]))
{
$number = $_POST['number'];
If (is_numeric($number))
{
$count = $_session['count'] + $number;
print "Last number entered: ".$number;
print "<br>Total internal numbers: ".$count;
}
}
?>
Im trying to store my $count
variable so each time i submit it outputs the total sum of the numbers entered