Hi all, Having a problem using http:// in a get variable. Obviously what its doing is splitting the variable as though i want to go to a new folder. I was wondering if anyone knew a way around this? sample code: <?php $get_url = $_GET['l']; if(isset($get_url)) echo $get_url; else echo 'No url posted'; ?> PHP: My error: You don't have permission to access / on this server. PHP: Thanks for any advice you offer.
Are you trying to get the full url http:// domain.com or some part of the url http:// domain.com/l=something?
Here is whats throwing me the error. Currently live on the server. http://api.slworkz.com/?l=http://www.test.com
Try urlencode(); <?php $get_url = urlencode($_GET['l']); // I'm not sure if thats the right format if(isset($get_url)) echo $get_url; else echo 'No url posted'; ?> PHP: EDIT: I just tried that and it seems to work, but you you might want to urldecode($get_url); your echo like this: <?php $get_url = urlencode($_GET['l']); if(isset($get_url)) echo urldecode($get_url); else echo 'No url posted'; ?> PHP:
Doesn't work. I'm afraid. Still gives same error because the problem is its not letting me access the script. Its splitting the URL in to different folders. So its looking for a folder that does not exist.
I'm lost sorry, I have no idea what your trying to do... my above answer works fine based on your first and second post.
Hiya, Sorry for the delay in responding, I had a visitor. Anyway, the problem is. When you type this url 'http://api.slworkz.com/?l=http://www.test.com in to your browser it will take you you to api.slworkz.com/?l=hhtp: and then it wont go any further as it think the next / is giving a new folder. Sorry if I am not describing this properly.
try using $_SERVER['QUERY_STRING'] to capture the GET Also you can try parse_url() function to receive the url and get parameters
Ok, I'll try that soon. need to get kids from school. Thanks all for your help. I'll post again soon.
I still have exactly the same error. I get no errors if I type in to the address bar api.slworkz.com/?l=www.test.com PHP: its only when I use http:// like here api.slworkz.com/?l=http://www.test.com PHP: api.slworkz.com is the subdomain of slworkz.com. Talk about driving me mental. lol. No point me adding anything to the script because its not actually reading the script. Thanks for your help guys
If you are typing the URL in browser directly, You can try removing the http:// part and when you have $l stored in the variable, just add it there. Like: go to: http://api.slworkz.com/?l=www.test.com/test.php In that script: $l= 'http://'. $_GET['l']; That will work. however, if you are creating a link like: <a href="http://api.slworkz.com/?l=http://www.test.com/test.php"> link </a> then it'd be better to do it like this: <a href="http://api.slworkz.com/?l=<?php echo urlencode('http://www.test.com/test.php'); ?>"> link </a> That should work. Thanks
Ok, If use a single letter as the GET tag as previously stated it throws the error. But if I use 'url' as the tag then the below code will work. <?php $get_url = $_GET['url']; if(isset($get_url)) echo $get_url; else echo 'No input'; ?> PHP: ?url=http://test.com is as good for me as ?l=http://test.com Thanks all for your help. Appreciated.