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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.