PDA

View Full Version : PHP help



Stefy09
30-03-2009, 12:19 AM
Hey can anyone help me on how to do this

So I have a form and in another file I have a variable which is eg. 1000.. on my form there's a field to input a number and when the person puts a number in it tells them how many numbers until the total number (1000)

How can I get it to echo to the person how much until the total?

Thanks

Dentafrice
30-03-2009, 12:34 AM
<?php
$number = 1000;

if($_POST) {
$user_number = $_POST['number'];
$difference = $number - $user_number;
echo "There are {$difference} numbers until {$number}.";
} else {
echo <<<HTML
<form method="post">
<label for="number"><strong>Number:</strong></label> <input type="text" name="number" />
<input type="submit" value="Submit" />
</form>
HTML;
}

Stefy09
30-03-2009, 12:51 AM
Thanks :)

Want to hide these adverts? Register an account for free!