Jump to content

[SOLVED] how to catch a >?< in the url please.


redarrow

Recommended Posts

 

advance thank you.

 

I want to catch any body that enters any think, in the query string but don't,

seem to no the code, can you help please.

 

<?php
//.'?' add that to $x will work as a test.

$x=$_SERVER['REQUEST_URI'];

$x=explode('.php',$x);

if(in_array('?',$x)){

echo " oi oi oi oi no no no no no";

exit;
}

?>

 

not working iver

<?php
//.'?' add that to $x will work as a test.

$x=$_SERVER['QUERY_STRING'];

$x=explode('.php',$x);

if(in_array('?',$x)){

echo " oi oi oi oi no no no no no";

exit;
}

?>

Link to comment
https://forums.phpfreaks.com/topic/144450-solved-how-to-catch-a-in-the-url-please/
Share on other sites

If a user is on the index page, and wanted to guess, variables,

i want to stop him/her by adding at the top off the page a way to see if a ? is aft her the .php

 

can you help please.

 

i have tried every think passable so far need help.

 

 

If a user is on the index page, and wanted to guess, variables,

i want to stop him/her by adding at the top off the page a way to see if a ? is aft her the .php

 

can you help please.

 

i have tried every think passable so far need help.

 

 

 

Just turn register globals off.

Well you could do parse_url but I just tested it and it doesn't work for the current page

 

print_r(parse_url($_SERVER['PHP_SELF']));

 

Prints

 

Array ( [path] => /url.php ) 

 

 

Do you mean you dont want people to guess variables you use in $_GET requests? If your script is properly set up and secured nobody should be able to adversely tamper with your script anyway.

<?php

$url=$_SERVER['PHP_SELF'].'?';

if(preg_match("/(\.php\?)/",$url ,$match)){

print_R($match);

echo " oi oi oi oi no no no no no";

exit;
}

?>

The if in the above code will always return TRUE because you are adding the ?  just do this:

<?php
if(preg_match('/\.php\?/', $_SERVER['REQUEST_URI']))
{
     die('oi oi oi oi no no no no no');
}

what exactly are you trying to achive

i put this code in test.php

<?php
if(strpos($_SERVER['REQUEST_URI'],"?")!== false){
echo "you put a ? in the URL ";
exit;
}
echo "you are ok";

and then went to

/test.php

and got "you are ok"

then went to

/test.php?

and got "you put a ? in the URL :("

isn't that what you want?

 

Scott.

 

 

yes all the examples work with a new loaded page it my fault your all correct.

 

 

This seems to be the better way theo, cheers everyone.

<?php
if(preg_match('/\.php\?/', $_SERVER['REQUEST_URI']))
{
     exit('oi oi oi oi no no no no no');
}
?>

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.