note 62782 added to function.is-int

From: Date: Thu, 09 Mar 2006 14:53:55 +0000
Subject: note 62782 added to function.is-int
Groups: php.notes 
Request: Send a blank email to php-notes+get-105145@lists.php.net to get a copy of this message
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> ---- Server IP: 84.18.202.180 Probable Submitter: 217.23.234.66 ---- X-Spam-Status: No, hits=4.2 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER, HTML_40_50,HTML_MESSAGE autolearn=no version=2.64 ---- Manual Page -- http://www.php.net/manual/en/function.is-int.php Edit -- http://master.php.net/note/edit/62782 Del: integrated -- http://master.php.net/note/delete/62782/integrated Del: useless -- http://master.php.net/note/delete/62782/useless Del: bad code -- http://master.php.net/note/delete/62782/bad+code Del: spam -- http://master.php.net/note/delete/62782/spam Del: non-english -- http://master.php.net/note/delete/62782/non-english Del: in docs -- http://master.php.net/note/delete/62782/in+docs Del: other reasons-- http://master.php.net/note/delete/62782 Reject -- http://master.php.net/note/reject/62782 Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#105145) next »