RE: Re[2]: [PHP] Newbie redirect/variable question

2001-05-11 Thread Steve Wade

Thanks - the hassle is - my isp doesn't use mysql - so i have to use text
files I reckon :-)

swadie


~~~
Steve Wade
Youth Outreach Coordinator
Fusion Australia Ltd (Sydney North)
ABN 26 001 273 105
+61 2 9477 1110


-Original Message-
From: James Holloway [mailto:[EMAIL PROTECTED]]
Sent: Friday, 11 May 2001 0:29
To: [EMAIL PROTECTED]
Subject: Re: Re[2]: [PHP] Newbie redirect/variable question


Steve,

The way you are doing things could leave yourself open with all kinds of
problems - one of which is address spoofing.  A better way would be to TEST
the link against values in the database before updating the link with a hit
and exiting.  Have the URL's marked against an auto-incremented id:

id: 23
name: Steve's page
url: http://www.somewhere.com

Url: redirect.php?id=23

redirect.php:


?

$check = @mysql_query(SELECT url FROM links WHERE id = '$id',
$connection);

if (mysql_num_rows($check) != 0) {
$update = @mysql_query(UPDATE links SET out = out + 1 WHERE id =
'$id', $connection);

while($row = mysql_fetch_array($check)) {
$url = $row['url'];
}

header(location: $url);
exit;

} else {

?
HTML
HEAD
TITLELink not found/TITLE
/HEAD
BODY

No corresponding link found!

/BODY
/HTML
? } ?



Much better that way, IMO. At present, if someone typed in a fake address,
the database would attempt to update a non-existant entry

You could go further, and log the IP of the user, and perhaps even set a
cookie if you were totally paranoid about people repeatedly clicking their
links so that they got more hits out.

Have fun ;)

James.


Steve Wade [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 Ahh - thanks - that's helped :-) (Line 9 was the http_referrer line)

 Now the only trouble is, it seems to still treat $fred as null.

 The passing line is from index.php:

 a href=redirect.php?fred=www.fusion.org.autest link/a

  Should this work?

 Thanks,

 Steve
 ~~~
 Steve Wade
 Youth Outreach Coordinator
 Fusion Australia Ltd (Sydney North)
 ABN 26 001 273 105
 +61 2 9477 1110


 -Original Message-
 From: Adaran (Marc E. Brinkmann) [mailto:[EMAIL PROTECTED]]
 Sent: Thursday, 10 May 2001 22:20
 To: [EMAIL PROTECTED]
 Subject: Re[2]: [PHP] Newbie redirect/variable question


 Hi Steve,

 Thursday, May 10, 2001, 1:39:36 PM, you wrote:
 Steve Ok - thanks - my new redirect.php is

 Steve ?php
 Steve if ($fred != ) {
 Steve # $statement = UPDATE links SET hits=hits+1 WHERE
href=\$u\;
 Steve # mysql_query($statement);
 Steve Header(Location: $fred);
 Steve exit;
 Steve } else {
 Steve Header(Location: $HTTP_REFERRER);
 Steve exit;
 Steve }
 ?

 Steve I get the following message...
 Steve Warning: Cannot add header information - headers already sent by
 (output
 Steve started at /home/swadie/public_html/redirect.php:2) in
 Steve /home/swadie/public_html/redirect.php on line 9

 Make sure you have NO Blanks or any other Text before the ?php ! ? has
 to be
 the first two characters in the file. Which line is line 9 ?

 ---
 EnjoY,
  Adaran ([EMAIL PROTECTED])
check http://www.adaran.net



 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]


 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]




--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re[2]: [PHP] Newbie redirect/variable question

2001-05-10 Thread Adaran (Marc E. Brinkmann)

Hi Steve,

Thursday, May 10, 2001, 1:39:36 PM, you wrote:
Steve Ok - thanks - my new redirect.php is

Steve ?php
Steve if ($fred != ) {
Steve # $statement = UPDATE links SET hits=hits+1 WHERE href=\$u\;
Steve # mysql_query($statement);
Steve Header(Location: $fred);
Steve exit;
Steve } else {
Steve Header(Location: $HTTP_REFERRER);
Steve exit;
Steve }
?

Steve I get the following message...
Steve Warning: Cannot add header information - headers already sent by (output
Steve started at /home/swadie/public_html/redirect.php:2) in
Steve /home/swadie/public_html/redirect.php on line 9

Make sure you have NO Blanks or any other Text before the ?php ! ? has to be
the first two characters in the file. Which line is line 9 ?

---
EnjoY,
 Adaran ([EMAIL PROTECTED])
   check http://www.adaran.net



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re[2]: [PHP] Newbie redirect/variable question

2001-05-10 Thread Adaran (Marc E. Brinkmann)

Hi Steve,

Thursday, May 10, 2001, 1:39:36 PM, you wrote:
Steve Ok - thanks - my new redirect.php is

Steve ?php
Steve if ($fred != ) {
Steve # $statement = UPDATE links SET hits=hits+1 WHERE href=\$u\;
Steve # mysql_query($statement);
Steve Header(Location: $fred);
Steve exit;
Steve } else {
Steve Header(Location: $HTTP_REFERRER);
Steve exit;
Steve }
?

Steve I get the following message...
Steve Warning: Cannot add header information - headers already sent by (output
Steve started at /home/swadie/public_html/redirect.php:2) in
Steve /home/swadie/public_html/redirect.php on line 9

Make sure you have NO Blanks or any other Text before the ?php ! ? has to be
the first two characters in the file. Which line is line 9 ?

---
EnjoY,
 Adaran ([EMAIL PROTECTED])
   check http://www.adaran.net



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: Re[2]: [PHP] Newbie redirect/variable question

2001-05-10 Thread Steve Wade

Ahh - thanks - that's helped :-) (Line 9 was the http_referrer line)

Now the only trouble is, it seems to still treat $fred as null.

The passing line is from index.php:

a href=redirect.php?fred=www.fusion.org.autest link/a

 Should this work?

Thanks,

Steve
~~~
Steve Wade
Youth Outreach Coordinator
Fusion Australia Ltd (Sydney North)
ABN 26 001 273 105
+61 2 9477 1110


-Original Message-
From: Adaran (Marc E. Brinkmann) [mailto:[EMAIL PROTECTED]]
Sent: Thursday, 10 May 2001 22:20
To: [EMAIL PROTECTED]
Subject: Re[2]: [PHP] Newbie redirect/variable question


Hi Steve,

Thursday, May 10, 2001, 1:39:36 PM, you wrote:
Steve Ok - thanks - my new redirect.php is

Steve ?php
Steve if ($fred != ) {
Steve # $statement = UPDATE links SET hits=hits+1 WHERE href=\$u\;
Steve # mysql_query($statement);
Steve Header(Location: $fred);
Steve exit;
Steve } else {
Steve Header(Location: $HTTP_REFERRER);
Steve exit;
Steve }
?

Steve I get the following message...
Steve Warning: Cannot add header information - headers already sent by
(output
Steve started at /home/swadie/public_html/redirect.php:2) in
Steve /home/swadie/public_html/redirect.php on line 9

Make sure you have NO Blanks or any other Text before the ?php ! ? has
to be
the first two characters in the file. Which line is line 9 ?

---
EnjoY,
 Adaran ([EMAIL PROTECTED])
   check http://www.adaran.net



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: Re[2]: [PHP] Newbie redirect/variable question

2001-05-10 Thread Jakob Kruse

You should probably urlencode the address first, like this:

a href=redirect.php?fred=?php echo urlencode(www.fusion.org.au)
?test link/a

Not sure if it solves the problem though.

Regards,
Jakob Kruse

Steve Wade [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 Ahh - thanks - that's helped :-) (Line 9 was the http_referrer line)

 Now the only trouble is, it seems to still treat $fred as null.

 The passing line is from index.php:

 a href=redirect.php?fred=www.fusion.org.autest link/a

  Should this work?

 Thanks,

 Steve
 ~~~
 Steve Wade
 Youth Outreach Coordinator
 Fusion Australia Ltd (Sydney North)
 ABN 26 001 273 105
 +61 2 9477 1110




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re[2]: [PHP] Newbie redirect/variable question

2001-05-10 Thread Steve Wade

Thanks - hmm - doesn't seem to do it though.

My current code is:

?php

if ($HTTP_GET_VARS['fred'] != ) {
# $statement = UPDATE links SET hits=hits+1 WHERE href=\$u\;
# mysql_query($statement);
header(Location: $HTTP_GET_VARS['fred']);
exit;
} else {
header(Location: $HTTP_REFERRER);
exit;
}
?

which gives an error msg:


Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or
`T_NUM_STRING' in /home/swadie/public_html/redirect.php on line 6


~~~
Steve Wade
Youth Outreach Coordinator
Fusion Australia Ltd (Sydney North)
ABN 26 001 273 105
+61 2 9477 1110


-Original Message-
From: Jakob Kruse [mailto:[EMAIL PROTECTED]]
Sent: Friday, 11 May 2001 0:00
To: [EMAIL PROTECTED]
Subject: Re: Re[2]: [PHP] Newbie redirect/variable question


You should probably urlencode the address first, like this:

a href=redirect.php?fred=?php echo urlencode(www.fusion.org.au)
?test link/a

Not sure if it solves the problem though.

Regards,
Jakob Kruse

Steve Wade [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 Ahh - thanks - that's helped :-) (Line 9 was the http_referrer line)

 Now the only trouble is, it seems to still treat $fred as null.

 The passing line is from index.php:

 a href=redirect.php?fred=www.fusion.org.autest link/a

  Should this work?

 Thanks,

 Steve
 ~~~
 Steve Wade
 Youth Outreach Coordinator
 Fusion Australia Ltd (Sydney North)
 ABN 26 001 273 105
 +61 2 9477 1110




--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: Re[2]: [PHP] Newbie redirect/variable question

2001-05-10 Thread Jakob Kruse

Well, that just means you have to rewrite the line:
header(Location: $HTTP_GET_VARS['fred']);
like this:
header(Location:  . $HTTP_GET_VARS['fred']);

But have you tried it with just $fred? You shouldn't have to use
$HTTP_GET_VARS.

Regards,
Jakob Kruse

Steve Wade [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 Thanks - hmm - doesn't seem to do it though.

 My current code is:

 ?php

 if ($HTTP_GET_VARS['fred'] != ) {
 # $statement = UPDATE links SET hits=hits+1 WHERE href=\$u\;
 # mysql_query($statement);
 header(Location: $HTTP_GET_VARS['fred']);
 exit;
 } else {
 header(Location: $HTTP_REFERRER);
 exit;
 }
 ?

 which gives an error msg:


 Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or
 `T_NUM_STRING' in /home/swadie/public_html/redirect.php on line 6


 ~~~
 Steve Wade
 Youth Outreach Coordinator
 Fusion Australia Ltd (Sydney North)
 ABN 26 001 273 105
 +61 2 9477 1110


 -Original Message-
 From: Jakob Kruse [mailto:[EMAIL PROTECTED]]
 Sent: Friday, 11 May 2001 0:00
 To: [EMAIL PROTECTED]
 Subject: Re: Re[2]: [PHP] Newbie redirect/variable question


 You should probably urlencode the address first, like this:

 a href=redirect.php?fred=?php echo urlencode(www.fusion.org.au)
 ?test link/a

 Not sure if it solves the problem though.

 Regards,
 Jakob Kruse

 Steve Wade [EMAIL PROTECTED] wrote in message
 [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
  Ahh - thanks - that's helped :-) (Line 9 was the http_referrer line)
 
  Now the only trouble is, it seems to still treat $fred as null.
 
  The passing line is from index.php:
 
  a href=redirect.php?fred=www.fusion.org.autest link/a
 
   Should this work?
 
  Thanks,
 
  Steve
  ~~~
  Steve Wade
  Youth Outreach Coordinator
  Fusion Australia Ltd (Sydney North)
  ABN 26 001 273 105
  +61 2 9477 1110




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: Re[2]: [PHP] Newbie redirect/variable question

2001-05-10 Thread James Holloway

Steve,

The way you are doing things could leave yourself open with all kinds of
problems - one of which is address spoofing.  A better way would be to TEST
the link against values in the database before updating the link with a hit
and exiting.  Have the URL's marked against an auto-incremented id:

id: 23
name: Steve's page
url: http://www.somewhere.com

Url: redirect.php?id=23

redirect.php:


?

$check = @mysql_query(SELECT url FROM links WHERE id = '$id',
$connection);

if (mysql_num_rows($check) != 0) {
$update = @mysql_query(UPDATE links SET out = out + 1 WHERE id =
'$id', $connection);

while($row = mysql_fetch_array($check)) {
$url = $row['url'];
}

header(location: $url);
exit;

} else {

?
HTML
HEAD
TITLELink not found/TITLE
/HEAD
BODY

No corresponding link found!

/BODY
/HTML
? } ?



Much better that way, IMO. At present, if someone typed in a fake address,
the database would attempt to update a non-existant entry

You could go further, and log the IP of the user, and perhaps even set a
cookie if you were totally paranoid about people repeatedly clicking their
links so that they got more hits out.

Have fun ;)

James.


Steve Wade [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 Ahh - thanks - that's helped :-) (Line 9 was the http_referrer line)

 Now the only trouble is, it seems to still treat $fred as null.

 The passing line is from index.php:

 a href=redirect.php?fred=www.fusion.org.autest link/a

  Should this work?

 Thanks,

 Steve
 ~~~
 Steve Wade
 Youth Outreach Coordinator
 Fusion Australia Ltd (Sydney North)
 ABN 26 001 273 105
 +61 2 9477 1110


 -Original Message-
 From: Adaran (Marc E. Brinkmann) [mailto:[EMAIL PROTECTED]]
 Sent: Thursday, 10 May 2001 22:20
 To: [EMAIL PROTECTED]
 Subject: Re[2]: [PHP] Newbie redirect/variable question


 Hi Steve,

 Thursday, May 10, 2001, 1:39:36 PM, you wrote:
 Steve Ok - thanks - my new redirect.php is

 Steve ?php
 Steve if ($fred != ) {
 Steve # $statement = UPDATE links SET hits=hits+1 WHERE
href=\$u\;
 Steve # mysql_query($statement);
 Steve Header(Location: $fred);
 Steve exit;
 Steve } else {
 Steve Header(Location: $HTTP_REFERRER);
 Steve exit;
 Steve }
 ?

 Steve I get the following message...
 Steve Warning: Cannot add header information - headers already sent by
 (output
 Steve started at /home/swadie/public_html/redirect.php:2) in
 Steve /home/swadie/public_html/redirect.php on line 9

 Make sure you have NO Blanks or any other Text before the ?php ! ? has
 to be
 the first two characters in the file. Which line is line 9 ?

 ---
 EnjoY,
  Adaran ([EMAIL PROTECTED])
check http://www.adaran.net



 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]


 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: Re[2]: [PHP] Newbie redirect/variable question

2001-05-10 Thread bill

On Fri, 11 May 2001, Steve Wade wrote:

 Thanks - hmm - doesn't seem to do it though.

 My current code is:

 ?php

 if ($HTTP_GET_VARS['fred'] != ) {
 # $statement = UPDATE links SET hits=hits+1 WHERE href=\$u\;
 # mysql_query($statement);
 header(Location: $HTTP_GET_VARS['fred']);
 exit;
 } else {
 header(Location: $HTTP_REFERRER);
 exit;
 }
 ?

 which gives an error msg:

 Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or
 `T_NUM_STRING' in /home/swadie/public_html/redirect.php on line 6


I noticed that you were passing the URL like this (from an earlier
message):

  a href=redirect.php?fred=www.fusion.org.autest link/a

if you put this in Location: without prefixing it with http://; it may be
treated as a local url or something that is not what you intend. I don't
think it is what is causing this specific error, but it could be the next
one :-))).




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re[2]: [PHP] Newbie redirect/variable question

2001-05-10 Thread Steve Wade

:-) :-)

Got it working - thanks heaps everyone :-)

Out of interest - here's my current redirect.php...


?php

if ($HTTP_GET_VARS['fred'] != ) {
# $statement = UPDATE links SET hits=hits+1 WHERE href=\$u\;
# mysql_query($statement);
$fred = $HTTP_GET_VARS['fred'];
header(Location: $fred);
exit;
} else {
header(Location: $HTTP_REFERRER);
exit;
}
?
 
and the updated referring code...

a href=redirect.php?fred=http://www.fusion.org.au;test link/a

Whew! Now to work on the hits counter bit...

swadie

~~~
Steve Wade
Youth Outreach Coordinator
Fusion Australia Ltd (Sydney North)
ABN 26 001 273 105
+61 2 9477 1110


-Original Message-
From: bill [mailto:[EMAIL PROTECTED]]
Sent: Friday, 11 May 2001 0:33
To: Steve Wade
Cc: PHP News
Subject: Re: Re[2]: [PHP] Newbie redirect/variable question


On Fri, 11 May 2001, Steve Wade wrote:

 Thanks - hmm - doesn't seem to do it though.

 My current code is:

 ?php

 if ($HTTP_GET_VARS['fred'] != ) {
 # $statement = UPDATE links SET hits=hits+1 WHERE href=\$u\;
 # mysql_query($statement);
 header(Location: $HTTP_GET_VARS['fred']);
 exit;
 } else {
 header(Location: $HTTP_REFERRER);
 exit;
 }
 ?

 which gives an error msg:

 Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or
 `T_NUM_STRING' in /home/swadie/public_html/redirect.php on line 6


I noticed that you were passing the URL like this (from an earlier
message):

  a href=redirect.php?fred=www.fusion.org.autest link/a

if you put this in Location: without prefixing it with http://; it may be
treated as a local url or something that is not what you intend. I don't
think it is what is causing this specific error, but it could be the next
one :-))).




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]