Log inUsernamePassword
Log me on automatically each visit    
Register
Register
Log in to check your private messages
Log in to check your private messages
CJ Webmaster Forums Forum Index -> PHP Scripts » CJ Send Page

   
Problem with dynamic links -(Solved) Goto page 1, 2  Next
View previous topic :: View next topic  
Author Message
Minki



Joined: 17 Sep 2003
Posts: 1

Posted: Wed Sep 17, 2003 7:30 pm    Post subject: Problem with dynamic links -(Solved)

Hi there! Great script. I have adapted it so it can retain the dynamic URL of the page because the $PHP_SELF just returned 'index.php'. Now it looks :

<a href="javascript:popUp('sendpage/friend.php?id2=<? echo "$PHP_SELF?n=$n&id=$id"; ?>');">Email to Friend</a>


I have changed the $id to $id2 everywere so it don't mixes up with my pages $id's and it seems to work, if you look at the status bar when you mouse-over the link it displays the right URL, say :

javascript:popUp('sendpage/friend.php?id2=/index.php?n=3&id=3);

which is the actual URL of that page, but when clicked the link, the form displays an incomplete URL, like

http://www.mydomain.com/index.php?n=3

the '&' and what goes behind is missing.

I would apreciate any kind of help.
Thnks
Back to top
James
CJ-Design.com Admin



Joined: 08 Nov 2002
Posts: 798
Location: UK

Posted: Sun Oct 19, 2003 2:28 am    Post subject:

the reason it does that is because the script treats the variables as seperate variables.

Try:

www.php.net/parse_url

i think
_________________
CJ Website Design Developer
Web Design - http://www.cj-design.com
Web Hosting - http://www.cj-hosting.com
Back to top
elkyle



Joined: 13 Feb 2005
Posts: 4

Posted: Mon Feb 14, 2005 1:01 am    Post subject: Found a work-around

Here's what I did to resolve this (a very irratating problem, might I add):

--Referring Page--
Code:
   echo '<a href="#" onClick="popUp(\'/sendpage/friend.php?link='.base64_encode($_SERVER['REQUEST_URI']).'\');"><img border="0" src="/graphics/email.gif"></a>';

--Referring Page--

--Friend.php--
Code:
<?
include("config.php");
[b]$_GET['link']=base64_decode($_GET['link']);[/b]
if(!isset($_GET['js']) || $_GET['js'] == ""){
   $link = $url.$_GET['link'];
}
else if($_GET['js'] == "on"){
   $link = $_GET['link'];
}

--Friend.php--

Note the third line in Friend.php. This must go here or else it will not work.

Explanation:

What this code does it it "base64 encode"'s the link that you are passing to the popup window. An example of base64 encoding:

Code:
Lot/s/"\of&TROU%BLI#NG-Chara:cter's

converts to:
Code:
TG90L3MvIlxvZiZUUk9VJUJMSSNORy1DaGFyYTpjdGVyJ3M=


This effectively removes the troubling ampersands from the picture.
Then, once it is in Friend.php, you just base64_decode the link and voila! You have a link with all the ampersands you want.

I have tested this, and it worked for me. If you happen to encouneter any problems, reply and I will get on it. Before I thought of this method, I had thought of a few less-pleasant solutions that I would implement only if I had to (one of them was using cookies, but it didn't work anyway (because of my site structure...not a problem with using cookies themselves))

Hope this helps anyone who was in the same conundrum as I was.

Please post comments on how elegant and inspired this solution is. You don't need to post if you are going to tell me that it is a "cheater" way of getting it accomplished...I already know that

Kyle
Back to top
blifaloo



Joined: 15 Mar 2005
Posts: 1

Posted: Tue Mar 15, 2005 10:36 pm    Post subject:

Phew... finally got it all working.

Thanks elkyle, a little tweaking to your posted code and it works fine now.

A few things:
in the friend code you have
Code:
 [b] and [/b]

Those don't belong there and will cause an error.
(I see you were just trying to bold that line for emphises, but I didn't catch that right away...and other folks might not as well)

Also for us folks who don't know much about php, the code you posted for the refering page should have the php begining/end-tag thingies:

Code:
<? echo '<a href="#" onClick="popUp(\'/sendpage/friend.php?link='.base64_encode($_SERVER['REQUEST_URI']).'\');"><img border="0" src="/graphics/email.gif"></a>'; ?>


At least, I needed them to work for my pages.

Thanks for the good solution, and I hope this helps other people.
Back to top
elkyle



Joined: 13 Feb 2005
Posts: 4

Posted: Wed Mar 16, 2005 12:39 am    Post subject:

Sorry about the confusion...

I anticipated that the bold tags would actually make that line bold...apparantly not.

Also, you were correct in that there should have been the appropriate php tags in the last example. I assumed that it was fairly obvious, but you know what they say about assuming...

(it makes a ass out of u and me )
Back to top
Catman



Joined: 15 Apr 2005
Posts: 3

Posted: Fri Apr 15, 2005 6:52 am    Post subject:

Hello guys. I don't have the ID problem, but I do have the problem that my Dynamic page urls are not being sent as the full url.

Is there a way to fix this with using javascript on the Referring Page, instead of the PHP that you posted?

Thanks,
Mike
Back to top
GodfatherUK
CJ-Design.com Moderator



Joined: 17 Sep 2004
Posts: 205
Location: UK

Posted: Fri Apr 15, 2005 3:26 pm    Post subject:

Im not sure how to implement it, as me and Javascript are like a cat with water .. but the code to bring up the referring url is

Code:
<script language="JavaScript">

<!--
document.write( document.referrer );
-->
</script>



Maybe one of the Code Guru's can give a hand with this
_________________
GodfatherUK
CJ Designs Forum Moderator

"I dont think i am good at coding.. But i KNOW im good at helping"
Back to top
PHPDUMMY
CJ-Design.com Moderator



Joined: 09 Mar 2005
Posts: 534
Location: South East Kentucky,U.S.A.

Posted: Fri Apr 15, 2005 8:53 pm    Post subject: How to properly pass the "&" in an URL

This is the proper way of passing the "&" in an URL,,,,,,,

&

Now , the "&" will properly be passed in any browser.

Forgive me if I misunderstood the initial query.....

Cheers,
Danny
Back to top
Catman



Joined: 15 Apr 2005
Posts: 3

Posted: Sat Apr 16, 2005 12:20 am    Post subject:

Thanks for the reply guys. The problem I am having, and I thought it was the same problem that was posted above, but here is the problem:

My dynamic page links look like this:

http://www.mydomain.com/cgi-bin/commerce.cgi?preadd=action&key=DJ1351-00

When I click on Send to Freind, this is the link it sends:

http://www.mydomain.com/cgi-bin/commerce.cgi?


It doesn't get the whole link. It stops after the "?". The page is a .html page, so I don't want to use SSI or PHP in it. I would like to use the JS like was provided when I did the install. But I need the JS modified so it will get the whole link and not just half of it. Just like elkyle made changes in his PHP for the refering page. But instead of PHP, I want to keep it as JS. Here is the original JS (I changed the folder name, but all else is the same.):

Code:
<!--
document.write("<a href=\"javascript:popUp('/recommend/friend.php?id=" +document.URL);
document.write("&js=on');\">Recommend to a Friend</a></p>");
//-->


Any suggestions?

Thanks,
Mike
Back to top
Catman



Joined: 15 Apr 2005
Posts: 3

Posted: Mon Apr 18, 2005 5:19 am    Post subject:

Does anyone know how to do this?


Thanks,
Mike
Back to top
elkyle



Joined: 13 Feb 2005
Posts: 4

Posted: Mon Apr 18, 2005 8:36 pm    Post subject: Javascript and incomplete URL issue

I may have found a solution for you:

Instead of using document.URL, try this:

Code:
<!--
document.write("<a href=\"javascript:popUp('/recommend/friend.php?id=" +document.location.href);
document.write("&js=on');\">Recommend to a Friend</a></p>");
//-->


I have tried it on my local web server, and document.location.href contains the entire url (in my case, http://localhost/personal/fullurl.html?test=abcd)

I hope this helps,

elkyle
Back to top
sbourdon



Joined: 07 Jan 2006
Posts: 8

Posted: Sat Jan 07, 2006 8:30 pm    Post subject:

Hello,

First post here!
Just installed CJ SendPage v2.0 (pop up) and must say that it looks great!

Only "looks" great because I can't keep a complete URL in my referrals...

I only want to include a link at the bottom of my phpBB forum; here's the code I have so far, in overall_footer.tpl:

Code:
<a href="#" onClick="popUp(\'/sendpage/friend.php?link='.base64_encode($_SERVER['REQUEST_URI']).'\');"><img src="images/recommander.gif" width="22" height="11" border="0" alt="{RECOMMEND}" hspace="3" />{RECOMMEND}</a><br />Powered by <a href="http://www.phpbb.com/" target="_phpbb" class="copyright">phpBB</a> © 2001, 2005 phpBB Group<br />{TRANSLATION_INFO}</span></div>



What am I missing here?

Thank you for your support!
Back to top
PHPDUMMY
CJ-Design.com Moderator



Joined: 09 Mar 2005
Posts: 534
Location: South East Kentucky,U.S.A.

Posted: Sat Jan 07, 2006 11:29 pm    Post subject:

sbourdon wrote:
Hello,

First post here!
Just installed CJ SendPage v2.0 (pop up) and must say that it looks great!

Only "looks" great because I can't keep a complete URL in my referrals...

I only want to include a link at the bottom of my phpBB forum; here's the code I have so far, in overall_footer.tpl:

Code:
<a href="#" onClick="popUp(\'/sendpage/friend.php?link='.base64_encode($_SERVER['REQUEST_URI']).'\');"><img src="images/recommander.gif" width="22" height="11" border="0" alt="{RECOMMEND}" hspace="3" />{RECOMMEND}</a><br />Powered by <a href="http://www.phpbb.com/" target="_phpbb" class="copyright">phpBB</a> © 2001, 2005 phpBB Group<br />{TRANSLATION_INFO}</span></div>



What am I missing here?

Thank you for your support!


the phpBB forum sometimes tries to sneak the footer in different areas.
_________________
Cheers,
Danny
C-J Search Engine All Tidied Up V4.0http://www.cj-design.com/forum/viewtopic.php?t=1820

C-J Search Engine MySQL !http://www.cj-design.com/forum/viewtopic.php?t=1555
Back to top
sbourdon



Joined: 07 Jan 2006
Posts: 8

Posted: Sun Jan 08, 2006 2:40 am    Post subject:

PHPDUMMY wrote:
sbourdon wrote:
Hello,

First post here!
Just installed CJ SendPage v2.0 (pop up) and must say that it looks great!

Only "looks" great because I can't keep a complete URL in my referrals...

I only want to include a link at the bottom of my phpBB forum; here's the code I have so far, in overall_footer.tpl:

Code:
<a href="#" onClick="popUp(\'/sendpage/friend.php?link='.base64_encode($_SERVER['REQUEST_URI']).'\');"><img src="images/recommander.gif" width="22" height="11" border="0" alt="{RECOMMEND}" hspace="3" />{RECOMMEND}</a><br />Powered by <a href="http://www.phpbb.com/" target="_phpbb" class="copyright">phpBB</a> © 2001, 2005 phpBB Group<br />{TRANSLATION_INFO}</span></div>



What am I missing here?

Thank you for your support!


the phpBB forum sometimes tries to sneak the footer in different areas.



So, what can I do to use this script with phpBB?

Thanks!
Back to top
PHPDUMMY
CJ-Design.com Moderator



Joined: 09 Mar 2005
Posts: 534
Location: South East Kentucky,U.S.A.

Posted: Sun Jan 08, 2006 12:29 pm    Post subject:

sbourdon wrote:
PHPDUMMY wrote:
sbourdon wrote:
Hello,

First post here!
Just installed CJ SendPage v2.0 (pop up) and must say that it looks great!

Only "looks" great because I can't keep a complete URL in my referrals...

I only want to include a link at the bottom of my phpBB forum; here's the code I have so far, in overall_footer.tpl:

Code:
<a href="#" onClick="popUp(\'/sendpage/friend.php?link='.base64_encode($_SERVER['REQUEST_URI']).'\');"><img src="images/recommander.gif" width="22" height="11" border="0" alt="{RECOMMEND}" hspace="3" />{RECOMMEND}</a><br />Powered by <a href="http://www.phpbb.com/" target="_phpbb" class="copyright">phpBB</a> © 2001, 2005 phpBB Group<br />{TRANSLATION_INFO}</span></div>



What am I missing here?

Thank you for your support!


the phpBB forum sometimes tries to sneak the footer in different areas.



So, what can I do to use this script with phpBB?

Thanks!


walk slowly through the phpBB code and make certain that its not something within their code that needs altering before going any further. i might be wrong but the best that i remember is that they used 2 entries for their copyright footer because they really want their copyright to remain there.
_________________
Cheers,
Danny
C-J Search Engine All Tidied Up V4.0http://www.cj-design.com/forum/viewtopic.php?t=1820

C-J Search Engine MySQL !http://www.cj-design.com/forum/viewtopic.php?t=1555
Back to top
Display posts from previous:   
       CJ Webmaster Forums Forum Index -> PHP Scripts » CJ Send Page All times are GMT
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

Powered by phpBB © 2001, 2002 phpBB Group
iCGstation v1.0 Template By Ray © 2003, 2004 iOptional, Mods by CJ Website Design