GoFuckYourself.com - Adult Webmaster Forum

GoFuckYourself.com - Adult Webmaster Forum (https://gfy.com/index.php)
-   Fucking Around & Business Discussion (https://gfy.com/forumdisplay.php?f=26)
-   -   php experts - simple php question? (https://gfy.com/showthread.php?t=710464)

roly 02-28-2007 03:00 PM

php experts - simple php question?
 
hi

i'm trying to make a very simple jump script for a particular reason and it works to a point but seems to give me an error.

i've got a redirect script link.php which contains the following:

Code:

<?php
$url = ($_GET['lnk']);
header("Location: $url");
exit;
?>

and i'm linking to a url like this:
Code:

http://www.somesite.com/?some-query-string!&id=27
and so i'm linking to my script like this:

Code:

http://mydomain.com/link.php?lnk=http://www.somesite.com/?some-query-string!&id=27
but it seems to be cutting off the string from the ampersand and sending it to:

Code:

http://www.somesite.com/?some-query-string!
and not to:

Code:

http://www.somesite.com/?some-query-string!&id=27
i know it's something stupid i'm doing wrong anyone got any ideas, it would be really appreciated :)

thanks in advance

Angelo22 02-28-2007 03:18 PM

id suggest setting a variable for each of the sites you 'lnk', then just link it to the variable.... might work that way

psili 02-28-2007 03:21 PM

try to urlencode(lnk) .. Query strings don't seem to dig two ? marks.

Briscoe 02-28-2007 03:27 PM

Quote:

Originally Posted by psili (Post 11989581)
try to urlencode(lnk) .. Query strings don't seem to dig two ? marks.

You are correct sir.

J.P. 02-28-2007 03:29 PM

Yep, the urlencode() will solve your problem...

roly 02-28-2007 03:48 PM

thanks guys for the responses. i've tried urlencode like this:

Code:

<?php

$url = urlencode($_GET['lnk']);

header("Location: $url");

exit;

?>

unfortunatly it now shows a 404 on my server with the url encoded but it isn't a 404 if i just use the unencoded string, am i using urlencode correctly in the above example?

roly 02-28-2007 04:17 PM

for anyone that's interested, i couldn't get it to work with urlencode, but this worked:

Code:

<?php

$url=substr($_SERVER['QUERY_STRING'],4);
header("Location: $url");

?>

thanks again

Ferrishyn 02-28-2007 04:24 PM

That'll work but you really should encode the ampersand in your address (you can use urlencode or replace &'s with %26). The reason its chopping off the end of it is the ampersand is splitting it into another GET variable:

$_GET['lnk'] and $_GET['id']

roly 02-28-2007 05:00 PM

Quote:

Originally Posted by Ferrishyn (Post 11989893)
That'll work but you really should encode the ampersand in your address (you can use urlencode or replace &'s with %26). The reason its chopping off the end of it is the ampersand is splitting it into another GET variable:

$_GET['lnk'] and $_GET['id']

ok thanks, i'll take a look another look at it.

Nookster 02-28-2007 05:16 PM

You really should sanatize your variables man. With the way it is there if I were a spammer I could use your script as my own redirect tool. And now that I think of it, using header like that to redirect complete url's is kinda dumb. Make a database hold the urls you want to use then call them by id. :2 cents: See sig for example.

roly 03-01-2007 10:32 AM

Quote:

Originally Posted by Nookster (Post 11990174)
You really should sanatize your variables man. With the way it is there if I were a spammer I could use your script as my own redirect tool. And now that I think of it, using header like that to redirect complete url's is kinda dumb. Make a database hold the urls you want to use then call them by id. :2 cents: See sig for example.

hi, i'm not a programmer, i was just coming up with a simple solution to a problem i had. when you say sanatize the urls do you mean by using urlencode like the others were saying?

regarding using an id to call the url's, that's a good idea, but i'm using autoblogger to post to blogs and this relates to my sourcelinks on the blog posts, and i can't edit the autoblogger code. this was my only solution i could think of for the particular problem i had.

Nookster 03-02-2007 11:16 PM

Quote:

Originally Posted by roly (Post 11993711)
hi, i'm not a programmer, i was just coming up with a simple solution to a problem i had. when you say sanatize the urls do you mean by using urlencode like the others were saying?

regarding using an id to call the url's, that's a good idea, but i'm using autoblogger to post to blogs and this relates to my sourcelinks on the blog posts, and i can't edit the autoblogger code. this was my only solution i could think of for the particular problem i had.

Aye, sorry for not catching your reply sooner for one.
Two, it's a fairly ok solution to your problem, but you leave your script vulnerable because, like I stated above, anyone can use it to forward their own url's to wherever with your script.
Ok, so you're a newbie to PHP. Read up on mysql man. With php and mysql you can do literally anything you want with a dynamic website. Not everyone has the mental abilities to understand code, so you may be part of the little percentage of people who can understand how it works and how to use it to your advantage. Check out the tutorials at programmingtutorials.com on mysql and php. I've taught myself everything I know about programming in general so I know it's possible for others to teach themselves the same. If you're serious about it hit me up and I'll help you out.

roly 03-06-2007 11:26 AM

Quote:

Originally Posted by Nookster (Post 12004867)
Aye, sorry for not catching your reply sooner for one.
Two, it's a fairly ok solution to your problem, but you leave your script vulnerable because, like I stated above, anyone can use it to forward their own url's to wherever with your script.
Ok, so you're a newbie to PHP. Read up on mysql man. With php and mysql you can do literally anything you want with a dynamic website. Not everyone has the mental abilities to understand code, so you may be part of the little percentage of people who can understand how it works and how to use it to your advantage. Check out the tutorials at programmingtutorials.com on mysql and php. I've taught myself everything I know about programming in general so I know it's possible for others to teach themselves the same. If you're serious about it hit me up and I'll help you out.


hi nookster, thanks for the advice. yeah i see what you mean about other people being able to use the script to forward there own urls. i think i have a new solution now. thanks again. :)


All times are GMT -7. The time now is 05:15 AM.

Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc123