I recently uploaded a program written in php. I tried running it on my server (with PHP version 4.4.1 installed) but it doesn't work. I finally reduced the problem down to 2 statements.
The following code does NOT work:
<code>
<br><br><center><b>Form Test</b></center><br><br>
<?php
print "<br>Create Form<br>\n";
print "
<form action=install2.php method=post>
<input type=hidden name=testnumber value=1>
<center><input type=submit value=\"Save test number\"></form>\n";
if ($testnumber == 1) {
print "Test number got set correctly<br>\n";
}
?>
</code>
However, if I insert the following $_Post line, it then functions correctly:
<code>
<br><br><center><b>Form Test</b></center><br><br>
<?php
print "<br>Create Form<br>\n";
print "
<form action=install.php method=post>
<input type=hidden name=testnumber value=1>
<center><input type=submit value=\"Save test number\"></form>\n";
$testnumber = $_POST['testnumber'];
if ($testnumber == 1) {
print "Test number got set correctly<br>\n";
}
?>
</code>
But to make the program function then, I would have to rewrite the whole program. Shouldn't the first code set the variable $testnumber without the $_POST command?
Thanks for any help.
I also don't seem to know how to post "highlighted code" on this forum. Thanks