phpinfo() Posted November 21, 2008 Share Posted November 21, 2008 I have a page that shows information based on the user id. ex. http://www.domain.com/page?u=10 The problem is, if u=letters, I get a SQL error. - Instead I would like to make it to where if someone enters u=letters, it just exits to page.php. - Basically u can only = integers. What would be the best way to do this?? - I already have it so if u= a user non-existant, it exits. But that only works for invalid numbers: $get = $_GET; $uupid = ($get['u']) ? $get['u'] : 0; if($uupid!=0) { $info1 = db_select("select user from accounts where user=$user"); if($uupid!=0 && $info1[0][0] == 0) { header("Location: page"); exit; } } Quote Link to comment Share on other sites More sharing options...
Caesar Posted November 21, 2008 Share Posted November 21, 2008 http://us2.php.net/is_integer Quote Link to comment Share on other sites More sharing options...
phpinfo() Posted November 21, 2008 Author Share Posted November 21, 2008 http://us2.php.net/is_integer How would I add this to the existing code? - Or what new codeset would I use with is_integer? Quote Link to comment Share on other sites More sharing options...
Caesar Posted November 21, 2008 Share Posted November 21, 2008 Also... http://us2.php.net/manual/en/function.is-numeric.php Also... <?php if(!preg_match('/[0-9]+/',$uid)) { //// Do the dew, dude. } ?> Quote Link to comment Share on other sites More sharing options...
Caesar Posted November 21, 2008 Share Posted November 21, 2008 http://us2.php.net/is_integer How would I add this to the existing code? - Or what new codeset would I use with is_integer? <?php if(!is_int($uid)) { //// Do the dew, dude. } ?> Quote Link to comment Share on other sites More sharing options...
phpinfo() Posted November 22, 2008 Author Share Posted November 22, 2008 Caesar, I have tried both methods and either continue to get the MySQL error if letters are entered for u= ; or I get a too many redirects browser error. Again, I am just trying to figure out how to get the page to exit if letters are entered for page?u= Any ideas / examples would be much appreciated. Thanks!!! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.