Jump to content

Easy PHP Question


holyearth

Recommended Posts

//form.php
[code=php:0]
<form action="process.php" method="post" target="submit">
Starting Number: <input type="text" name="startnum" /><br />
Numbers: <input type="text" name="numbers" /><br />
<select name="updown">
<option value="up">Increment</option>
<option value="down">Decrement</option>
</select><br />
<input type="submit" name="submit" value="Submit" />
</form>
[/code]

//process.php
[code=php:0]
<?php
$startnum = $_POST['startnum']; //starting number
$numbers = $_POST['numbers']; //increment of
$updown = $_POST['updown']; //increasing or decreasing
$endnum = $startnum + $numbers; //ending number

$num_array = ($updown == "up") ? range($startnum, $endnum) : range($endnum, $startnum);

foreach($num_array as $key=>$val)
{
  $urlstring .= "n" . ($key+1) . "=" . $val . "&";
}
$urlstring = "submit.php?" . substr($urlstring, 0, -1);

header("Location: $urlstring");
?>
[/code]

//submit.php
Whatever goes here...
Link to comment
https://forums.phpfreaks.com/topic/23916-easy-php-question/#findComment-108743
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.