note 62782 rejected from function.is-int by betz
| From: | betz@php.net | Date: | Thu, 09 Mar 2006 16:15:06 +0000 |
| Subject: | note 62782 rejected from function.is-int by betz | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-105150@lists.php.net to get a copy of this message | ||
Note Submitter: elaineseery at hotmail dot com
----
i had learnt the hard way that all form input is submitted as a string - but maybe not always? the
example below works without casting $_POST['age'] as an int...
<?php
// retrieve form data
$age = $_POST['age'];
// check entered value and branch
if ($age >= 21) {
echo 'Come on in, we have alcohol and music awaiting you!';
}
else {
echo 'You\'re too young for this club, come back when you\'re a little
older';
}
?>
<form id="form1" name="form1" method="post" action="">
<label for="age">Your Age</label>
<input type="text" name="age" id="age" />
<input type="submit" name="Submit" value="Submit"
id="Submit" />
</form>