oli22 Posted September 9, 2010 Share Posted September 9, 2010 Trying to get this done: Page_1 has many external links, when certain links are clicked i do not want user to go directly to page, but rather go to a special add page_2 where user must click a second time on the link to finally get there. The add page_2 must show on screen the name of the initial link from page_1, it must change accordingly with the link it came from page_1,once on page_2 the hyperlink redirects outside the site. So far i am thinking give an id to the div or "<a href..." on page_1 then somehow have page_2 detect that id and fill in the variable for the final external link. Other wise is there a way to detect a url from incoming? I guess a similar example is how some domain name sellers landing page will indicate the name of the site. Such as "Thisdomain.com" is for sale. same landing page but the name changes according to the domain that was typed. Quote Link to comment Share on other sites More sharing options...
schilly Posted September 9, 2010 Share Posted September 9, 2010 <a href="page2.php?url=<?=urlencode($url_clicked)?>">Link Title</a> Then on page2.php just use $_GET['url'] to obtain the url they clicked. Quote Link to comment Share on other sites More sharing options...
oli22 Posted September 9, 2010 Author Share Posted September 9, 2010 I tried to apply this many ways and i don't know how. I am really new to php so i will ask if you can please explain further. Here is the basic code layout: How exactly would you do it, for example if i had a link for http://www.google.ca Page1.php: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> </head> <body> <div> <a href="page2.php?url=<?=urlencode($url_clicked)?>">Link Title</a> </div> </body> </html> Page2.php: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> </head> <body> <div> $_GET['url'] </div> </body> </html> Quote Link to comment Share on other sites More sharing options...
schilly Posted September 9, 2010 Share Posted September 9, 2010 $url_clicked was just an example of a possible URL. Just replace it with the link you want if you are not generating the URLs dynamically. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> </head> <body> <div> <a href="page2.php?url=<?=urlencode("http://mysite.com")?>">Link Title</a> </div> </body> </html> Then for accessing the URL: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> </head> <body> <div> <?=$_GET['url']?> </div> </body> </html> Quote Link to comment Share on other sites More sharing options...
oli22 Posted September 9, 2010 Author Share Posted September 9, 2010 First page had " " twice so i added singles ' ' <a href="page2.php?url=<?=urlencode('http://www.google.ca')?>">Google</a> Second page result is empty, nothing shows. I thought i was going to see somekind of a google link? Quote Link to comment Share on other sites More sharing options...
schilly Posted September 9, 2010 Share Posted September 9, 2010 Is the URL variable populated in the address bar in your browser when you click the link? Your server might not have short tags enabled so you may have to do this: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> </head> <body> <div> <a href="page2.php?url=<?php echo urlencode("http://mysite.com"); ?>">Link Title</a> </div> </body> </html> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> </head> <body> <div> <?php echo urldecode($_GET['url']); ?> </div> </body> </html> Quote Link to comment Share on other sites More sharing options...
oli22 Posted September 9, 2010 Author Share Posted September 9, 2010 I am trying the new code...in a fiew seconds As for your question my url bar says this: http://127.0.0.1/URL_tester/page2.php?url= 127.0.0.1---> i am using easyPHP on my computer Quote Link to comment Share on other sites More sharing options...
oli22 Posted September 9, 2010 Author Share Posted September 9, 2010 Ok it is partially functional ! It is effectively returning the " http://mysite.com " value to page2.php so i inserted it into a hyperlink like this: Proceed to: <a href="<?php echo urldecode($_GET['url']); ?>"> </a> Finally how do i get the value of "Link Title" on page1.php to appear in the <a href.....> make it appear here </a> The reason is many outbound links will go to the same add page before user leaves site so far i was trying to use the same technique, but still haven't found. Quote Link to comment Share on other sites More sharing options...
schilly Posted September 10, 2010 Share Posted September 10, 2010 You'll need to pass that info through the first url as well. <a href="page2.php?url=<?php echo urlencode("http://mysite.com"); ?>&title=<?php echo urlencode("Link Title"); ?>">Link Title</a> Then similar on page 2. <a href="<?php echo urldecode($_GET['url']); ?>"><?php echo urldecode("Link Title"); ?></a> Quote Link to comment Share on other sites More sharing options...
oli22 Posted September 10, 2010 Author Share Posted September 10, 2010 That was almost it except that <a href="<?php echo urldecode($_GET['url']); ?>"><?php echo urldecode("Link Title"); ?></a> is---------------------------------------------------------------- <?php echo urldecode($_GET['title']);?></a> I guess you wanted to see if i was listening! As i said links will go to this add page and i the only thing i want to edit on this page is the adds. The rest is automatic. Thank you so much for your help This is fresh of the shelf so i may still develop this idea further: Like the capacity to turn this script on and off, still got energy today? Quote Link to comment Share on other sites More sharing options...
oli22 Posted September 10, 2010 Author Share Posted September 10, 2010 Thank you for the awesome help Quote Link to comment Share on other sites More sharing options...
schilly Posted September 10, 2010 Share Posted September 10, 2010 Ah caught my error. Typing and copy/paste too fast =) glad it's working. Quote Link to comment Share on other sites More sharing options...
oli22 Posted November 3, 2010 Author Share Posted November 3, 2010 Hi i'm back Now i would like to be able to turn this script on and off depending on if i want to show users an exit message or not when they click external link. So instead of having link go from page1 to page2 to external link, hyperlink would go from page1 directly to external link. I was thinking that it would be possible with a if/else and a true/false boolean, what do you suggest? This is the script so far: <body> <div> <a href="page2.php?url=<?php echo urlencode("http://www.google.ca"); ?>&title=<?php echo urlencode("google"); ?>">google</a> </div> </body> page2: <body> <div> proceed to<a href="<?php echo urldecode($_GET['url']); ?>"> <?php echo urldecode($_GET['title']); ?> </a> </div> </body> Quote Link to comment Share on other sites More sharing options...
oli22 Posted November 11, 2010 Author Share Posted November 11, 2010 This is my amateur logic so far, but of course it is mot working, help me please anyone! I have modified the second page like this: <body> <div> <?php $ad_linker=TRUE; $URL= <?php echo urldecode($_GET['url']); ?> ; ?> <?php if ($ad_linker=TRUE) { echo "proceed to<a href="<?php echo urldecode($_GET['url']); ?>"> <?php echo urldecode($_GET['title']); ?> </a>" ; } else($ad_linker=false) { echo "header("Location: $URL ")"; } ?> </body> Quote Link to comment Share on other sites More sharing options...
oli22 Posted November 12, 2010 Author Share Posted November 12, 2010 This is another idea for page2, but still not working Parse error on -->$linker=TRUE ??? <body> <div> <?php $linker=TRUE if(linker==TRUE) { echo "proceed to" <a href= <?php echo urldecode($_GET['url']); ?>> <?php echo urldecode($_GET['title']); ?> </a> } else { echo header('Location: '.$_GET['url']); exit(); } ?> </body> Could someone please help me clean and fix it?:'( Quote Link to comment Share on other sites More sharing options...
oli22 Posted November 12, 2010 Author Share Posted November 12, 2010 :'( Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted November 12, 2010 Share Posted November 12, 2010 Add a line termination (semicolon) to it. Quote Link to comment Share on other sites More sharing options...
oli22 Posted November 12, 2010 Author Share Posted November 12, 2010 ok Pikachu2000 i did this <body> <div> <?php $linker=TRUE; if(linker==TRUE) { echo "proceed to" <a href= <?php echo urldecode($_GET['url']); ?>> <?php echo urldecode($_GET['title']); ?> </a>; } else { echo header('Location: '.$_GET['url']); exit(); } ?> </body> but i get error here: Parse error: parse error, expecting `','' or `';'' in C: on line 19 Line19 is echo "proceed to" <a href= <?php echo urldecode($_GET['url']); ?>> <?php echo urldecode($_GET['title']); ?> </a>; Quote Link to comment Share on other sites More sharing options...
oli22 Posted November 12, 2010 Author Share Posted November 12, 2010 Did it all on my own. Thread closed Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.