Jump to content

Archived

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

holyearth

Easy PHP Question

Recommended Posts

Post your code and tell us what part your stuck on.

Share this post


Link to post
Share on other sites
//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...

Share this post


Link to post
Share on other sites

×

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.