Jump to content

How to do something with a variable


champbronc2

Recommended Posts

OK so I have a url and it looks like Http://www.example.com/example.php?ad=###

 

What I want to do is something like this:

 

$ad_id=limpiar($_GET["ad"]);
if '$ad_id LIKE %0% OR contains %abcdefghijklmnopqrstuvwxyz%{
echo '$user=uc($_COOKIE["usNick"]);
$delete = "DELETE FROM users
WHERE username='$user'"
$go = mysql_query($delete)
"Account deleted! Stop cheating"
}
else
{

 

I realize that this code is complete garbage because it is wrong. I don't know the commands but I am trying to show you what I need it to do.

 

Can anyone give me the code to do what I am trying to do?

Link to comment
Share on other sites


$ad_id = $_GET['id'];

if ( (ereg("[^[:digit:]]", $ad_id)) || ($ad_id == 0) ){

$user = uc($_COOKIE['usNick']);

$del = "DELETE FROM users WHERE username = '$user'";
$go  = mysql_query($del)or trigger_error("Could not delete account");

echo "Account deleted! Stop cheating!!!";

}else{

rest of code...

}

 

Is that what you want?

Link to comment
Share on other sites

Although quite frankly this is a bad way to handle cheaters, if people are cheating on your site then it's your own fault as you should have made it secure. Cheaters also help you to make your site secure if you missed any security holes/exploits as they will probably end up reporting the problem to you...

Link to comment
Share on other sites


$ad_id = $_GET['ad']; //Shouldn't that be getting the ad variable not id?

if ( (ereg("[^[:digit:]]", $ad_id)) || ($ad_id == 0) ){

$user = uc($_COOKIE['usNick']);

$del = "DELETE FROM users WHERE username = '$user'";
$go  = mysql_query($del)or trigger_error("Could not delete account");

echo "Account deleted! Stop cheating!!!";

}else{

rest of code...

}

 

Is that what you want?

No I don't think that would work because wouldn't that flag anyone viewing http://www.example.com/view.php?ad=###

 

I only want it to flag people if the # in the ad URL variable has a zero or letters in it.

 

I got this when I went to this url http://www.example.com/view.php?ad=0

Fatal error: Call to undefined function uc() in /home/champbux/public_html/betaview.php on line 7

 

And when I tried http://www.example.com/view.php?ad=0123 it didn't flag it.

Link to comment
Share on other sites

$ad_id = $_GET['ad'];

preg_match( /(.*)0(.*)/,$ad_id,$match); //if you just want to find 0's at the beginning of the string then replace (.*)0(.*) with 0(.*)

if ( !is_int($ad_id) || isset($match[0]) )
{

$user = uc($_COOKIE['usNick']); //if function uc() does not existing thn this should be $user = $_COOKIE['usNick'];

$del = "DELETE FROM users WHERE username = '$user'";
$go  = mysql_query($del)or trigger_error("Could not delete account");

echo "Account deleted! Stop cheating!!!";

}else{

rest of code...

}

 

Don't worry about the $5.

Link to comment
Share on other sites

preg_match( /(.*)0(.*)/,$ad_id,$match); //if you just want to find 0's at the beginning of the string then replace (.*)0(.*) with 0(.*)

 

Should be

preg_match('/(.*)0(.*)/',$ad_id,$match); //if you just want to find 0's at the beginning of the string then replace (.*)0(.*) with 0(.*)

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.