help with register globals
Posted: Fri Jan 29, 2010 9:52 am
Hello all, I am very new to php and am having difficulty with a very simple form. When I upload the page with register_globals off, it works fine. I know that register_globals should be turned on and so I added some code to the page and turned them on, but can't seem to get the code to work. This is supposed to be a very simple project for a class, but has kept me busy for hours. Any suggestions would be greatly appreciated.
Thank you. I've posted the code below
Thank you. I've posted the code below
Code: Select all
<html>
<head>
<title>The Count</title>
<style type="text/css">
@import url("style.css");
</style>
</head>
<body>
<div id="main">
<div id="left">
</div>
<div id="top">
<h1 class="largeText">The number you chose is...</h1>
<img class="imageFloat" src="images/count.png " />
<div id="right">
<?php
$whatNumber = $_POST['whatNumber'];
echo $whatNumber;
?>
</div>
</div>
<div id="bottom">
<form method="POST">
<h2>Choose any number, positive or negative.</h2>
<input type="text" name="whatNumber" size="10" maxlength="10">
<h2>Choose a method of counting</h2>
<select name="choose">
<option value = "f">Count using a for loop</option>
<option value = "fe">Count using a for each loop</option>
<option value = "w">Count using a while loop</option>
</select>
<input type="submit" value="Start Counting">
</form>
<?php
$whatNumber = $_POST['whatNumber'];
$count = 0;
switch($choose){
case "w" :
if ($whatNumber >=0) {
while ($count <= $whatNumber) {
echo $count."\n";
$count++;
}
}else if ($whatNumber<=0) {
while ($count >= $whatNumber) {
echo $count."\n";
$count--;
}
}
break;
case "f":
for ($count=0; $count <= $whatNumber; $count++) {
echo $count."\n";
}
for ($count=0; $count >= $whatNumber; $count--) {
echo $count."\n";
}
break;
case "fe":
$numbers = range(0,$whatNumber);
foreach ($numbers as $number) {
echo $number."\n";
}
break;
}
?>
</div>
</body>
</html>