Re: Form and If command



Nico wrote:
Dear All,

I'm new in the Php world and am trying to do my first trials (with included errors :).
At the present I created a simple form:

<FORM METHOD="POST" ACTION="test.php">
<INPUT TYPE="text" NAME="amount" SIZE="10" MAXLENGHT="20">
<INPUT TYPE="SUBMIT" VALUE="SUBMIT">
</FORM>

Then, in the test.php page I've included the following code:
<?php
echo $_REQUEST["amount"];
?>

In the field "amount" of the form it will be inserted a number.
I'd like to create a string which make the following operations:

if the inserted amount is < or = to 1 go to the URL http://www.....
if the inserted amount is > 1 go to the URL http://www.....

I've some problem because don't know if I can use something like "if "amount = 1 ... " or not.
Can you help me please?
Many thanks.


<?php
// ad hoc, non-tested solution
if (isset($_POST['amount']) && is_numeric($_POST['amount'])) {
if ($_POST['amount'] > 1) {
header("Location: http://www...";);
}
else {
header("Locatoin: http://www...";);
}
}
?>
<!-- rest of your script here, eg. the form -->
.



Relevant Pages

  • Re: webcollab, php5.0 and ctype [SOLVED]
    ... PHP loads different modules depending on how it is called. ... Nico ... > just in case) ctype still doesn't seem to be available. ... > Sony Service Center (NSCE) ...
    (Debian-User)
  • Re: Public IP auf Webseite anzeigen lassen
    ... Ansonsten gibts das auch in PHP. ... Nur in Javascript eben nicht. ... Nico ...
    (de.comp.lang.javascript)
  • Re: Sessions
    ... Nico wrote: ... I tried to use the sessions, ... Can you help me in solving this problem please? ...
    (comp.lang.php)
  • Re: get all the email addresses from a text file
    ... Nico wrote: ... would like to get all the email addresses in a $mails[] variable. ... anyone know how to do this in php. ... (Please don't say HTML) ...
    (comp.lang.php)
  • Re: Form and If command
    ... Erwin Moller wrote: ... I'm new in the Php world and am trying to do my first trials (with ... The use of $_REQUEST mainly shows to others you don't know where to expect ...
    (comp.lang.php)