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; } } Link to comment https://forums.phpfreaks.com/topic/133689-url-get-help-preg_match-is_int/ Share on other sites More sharing options...
Caesar Posted November 21, 2008 Share Posted November 21, 2008 http://us2.php.net/is_integer Link to comment https://forums.phpfreaks.com/topic/133689-url-get-help-preg_match-is_int/#findComment-695635 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? Link to comment https://forums.phpfreaks.com/topic/133689-url-get-help-preg_match-is_int/#findComment-695637 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. } ?> Link to comment https://forums.phpfreaks.com/topic/133689-url-get-help-preg_match-is_int/#findComment-695638 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. } ?> Link to comment https://forums.phpfreaks.com/topic/133689-url-get-help-preg_match-is_int/#findComment-695640 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!!! Link to comment https://forums.phpfreaks.com/topic/133689-url-get-help-preg_match-is_int/#findComment-695916 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.