Page 1 of 1

Incrementing Over Multiple Pages

Posted: Thu Aug 09, 2007 7:18 am
by compguru910
Im relatively new to PHP, and i have a question about incrementing variables over multiple pages.
What im trying to do is have it so that every time the user presses a button, it increments the variable "counter" once. Now, with my script, the counter variable will increment once, the first time the submit button is pressed, but how do I get it to increment every time the button is clicked? Here is my script

Code: Select all

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>
<?php
if (isset ($_POST['button'])) {
$counter += 1;
print 'Counter: ' . $counter . '<br />';
print 'Submit  Button Has been pushed <br />';
print '<form id="form1" name="form1" method="post" action="testisset.php">';
print '<input type="submit" name="button" id="button" value="Submit" />';
print '</form>';
}else{
print '<form id="form1" name="form1" method="post" action="testisset.php">';
print '<input type="submit" name="button" id="button" value="Submit" />';
print '</form>';
}
?>
</body>
</html>
Also, im trying to make this script work with the Image Type Input. I dont know how well this input works with php, because when I use it, it doesnt ever see it as "Set". Heres my code for that

Code: Select all

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>
<?php
if (isset ($_POST['button'])) {
$counter += 1;
print 'Counter: ' . $counter . '<br />';
print 'Submit  Button Has been pushed <br />';
print '<form id="form1" name="form1" method="post" action="testisset.php">';
print '<input type="image" src="player/back.jpg" name="button" id="button" value="Submit" />';
print '</form>';
}else{
print '<form id="form1" name="form1" method="post" action="testisset.php">';
print '<input type="image" src="player/back.jpg" name="button" id="button" value="Submit" />';
print '</form>';
}
?>
</body>
</html>
Any suggestions would be appreciated. Thank you