Search code examples
phphref

Insert PHP variable in external link


The link works perfectly fine internally on the domain, just won't work for an external website. Didn't see anything in the documentation. I provided an example below. Would appreciate some insight.

<?php $user = basename($_SERVER['PHP_SELF']);?>

<a href="https://www.externaldomain.com/secure/cart/addItem.aspx?qty=1&itID=9135&PromoID=83&uid=<?php echo $user->username ?>">

Solution

  • Based on you comment, you must have a page url like page.php?ID=userid and you want something like this: {externalpage.com/page.php}?uid=userid

    Try:

    <a href="https://www.externaldomain.com/secure/cart/addItem.aspx?qty=1&itID=9135&PromoID=83&uid=<?php echo $_GET["ID"]; ?>">
    

    Edit

    Based on your last comment, try this:

    <?php $user = basename($_SERVER['PHP_SELF']);?>
    <a href="https://www.externaldomain.com/secure/cart/addItem.aspx?qty=1&itID=9135&PromoID=83&uid=<?php echo $user; ?>">