Morning everyone --

Can anyone help me with what is probably very simple?

I have a page where I want to get a variable from the URL and insert it in the buy button... so if my url is http://mywebsite.com/hangout?id=beauty

I want when someone click the button Buy to go to http://affiliatewebsite.com/join?id=beauty

Thanks in advance!

Recommended Answers

All 5 Replies

In my view alone html is not capable of doing so.
What is your server side language?

As default it's php. Thanks

In your file you can read passed get or post variables using php arrays $_GET AND $_POST in your case, its get variable id

Now we set new link in your hangout.php as following

hangout.php

<a href='http://affiliatewebsite.com/join?id=<?php echo $_GET['id']?>' > click here to join </a>

Hi,
If the id is stored in session you can write the link like this:

<?php
    session_start();
?>
.... part of the page .....
<a href='http://affiliatewebsite.com/join?id=<?php echo $_SESSION['id']?>' > click here to join </a>
... rest of the page ....

or a button

<button id="join_button" onclick="<?php header( 'Location:  http://affiliatewebsite.com/join?id='.$_SESSION['id'])">Join</button>

Thank you Utrivedi, It works like a charm

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.