Jump to content

URL / GET help - preg_match, is_int???


phpinfo()

Recommended Posts

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

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!!!

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.