Welcome to the GoFuckYourself.com - Adult Webmaster Forum forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Post New Thread Reply

Register GFY Rules Calendar Mark Forums Read
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >
Discuss what's fucking going on, and which programs are best and worst. One-time "program" announcements from "established" webmasters are allowed.

 
Thread Tools
Old 02-28-2007, 03:00 PM   #1
roly
Confirmed User
 
Join Date: Aug 2002
Posts: 1,844
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
roly is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 02-28-2007, 03:18 PM   #2
Angelo22
Writer
 
Angelo22's Avatar
 
Industry Role:
Join Date: Feb 2007
Posts: 3,123
id suggest setting a variable for each of the sites you 'lnk', then just link it to the variable.... might work that way
__________________
MAKE MORE MONEY FROM YOUR WEB TRAFFIC - 15% BONUS

And contact me if you need high quality translating and writing work done - angelo22 (AT) gmail (DOT) com
Angelo22 is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 02-28-2007, 03:21 PM   #3
psili
Confirmed User
 
Join Date: Apr 2003
Location: Loveland, CO
Posts: 5,526
try to urlencode(lnk) .. Query strings don't seem to dig two ? marks.
__________________
Your post count means nothing.
psili is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 02-28-2007, 03:27 PM   #4
Briscoe
Confirmed User
 
Join Date: Mar 2003
Location: Las Vegas
Posts: 153
Quote:
Originally Posted by psili View Post
try to urlencode(lnk) .. Query strings don't seem to dig two ? marks.
You are correct sir.
__________________
Earn up to 70% per sale and 15% on webmaster referrals
Signup for Horny Teen Cum Sluts
A CCBill and NoCreditCard partner
Briscoe is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 02-28-2007, 03:29 PM   #5
J.P.
Confirmed User
 
Join Date: Jun 2004
Posts: 689
Yep, the urlencode() will solve your problem...
__________________
Webmasters! Looking for new affiliate programs to promote?
Affiliate Program Search <-- Search for programs with FHGs, RSS feed, specific niche sponsors, ...
J.P. is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 02-28-2007, 03:48 PM   #6
roly
Confirmed User
 
Join Date: Aug 2002
Posts: 1,844
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 is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 02-28-2007, 04:17 PM   #7
roly
Confirmed User
 
Join Date: Aug 2002
Posts: 1,844
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
roly is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 02-28-2007, 04:24 PM   #8
Ferrishyn
Registered User
 
Join Date: Nov 2005
Posts: 28
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']
Ferrishyn is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 02-28-2007, 05:00 PM   #9
roly
Confirmed User
 
Join Date: Aug 2002
Posts: 1,844
Quote:
Originally Posted by Ferrishyn View Post
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.
roly is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 02-28-2007, 05:16 PM   #10
Nookster
Confirmed IT Professional
 
Industry Role:
Join Date: Nov 2005
Location: Hollywood, CA
Posts: 3,744
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. See sig for example.

Last edited by Nookster; 02-28-2007 at 05:18 PM..
Nookster is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 03-01-2007, 10:32 AM   #11
roly
Confirmed User
 
Join Date: Aug 2002
Posts: 1,844
Quote:
Originally Posted by Nookster View Post
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. 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.
roly is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 03-02-2007, 11:16 PM   #12
Nookster
Confirmed IT Professional
 
Industry Role:
Join Date: Nov 2005
Location: Hollywood, CA
Posts: 3,744
Quote:
Originally Posted by roly View Post
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.
Nookster is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 03-06-2007, 11:26 AM   #13
roly
Confirmed User
 
Join Date: Aug 2002
Posts: 1,844
Quote:
Originally Posted by Nookster View Post
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.
roly is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Post New Thread Reply
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >

Bookmarks
Thread Tools



Advertising inquiries - marketing at gfy dot com

Contact Admin - Advertise - GFY Rules - Top

©2000-, AI Media Network Inc



Powered by vBulletin
Copyright © 2000- Jelsoft Enterprises Limited.