Jump to content

How to read incoming url ? Read hyperlink from same site


oli22

Recommended Posts

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.

 

 

 

Link to comment
Share on other sites

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>

Link to comment
Share on other sites

 

$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>

 

Link to comment
Share on other sites

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>

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

;) 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?

Link to comment
Share on other sites

  • 1 month later...

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>

 

 

Link to comment
Share on other sites

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>

Link to comment
Share on other sites

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?:'(

Link to comment
Share on other sites

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>;
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.