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

 

 

 

Just turn register globals off.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

if(strpos($_SERVER,"?")!== false){
echo "you put a ? in the URL ";
exit;
}

that what you want??

 

Scott.

 

I'm not sure what that meant to do, $_SERVER is an array for starters.

 

if (isset($_SERVER['QUERY_STRING'])) {
  // do whatever.
}

Link to comment
Share on other sites

<?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');
}

Link to comment
Share on other sites

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.

 

 

Link to comment
Share on other sites

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');
}
?>

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.