Jump to content

PHP Absolute link shows up as relative - Help!


jmpetre

Recommended Posts

OK, let me preface this by saying that I am not a PHP programmer, but I need to hack this code snippet that was given to me.  I have a php invoicing program running on my webserver, and I want to insert this piece of code into the invoices so my customers can pay via PayPal:

<?php 
    $amount = number_format($row->total_with_tax - $row->amount_paid, 2, '.', '');
    $link = urlencode("https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&currency_code=USD&business=$companyInfo->primary_contact_email&amount=$amount&item_name=$row->name - Invoice $row->invoice_number");
    
    echo "<p>Pay the balance using PayPal - <a href='$link'>Click Here</a></p>";
    
    ?> 

 

The problem is, when I click on the link this generates, it tacks the link on like a relative link.  It looks like this:

http://www.abc.com:8080/index.php/invoices/view/https://www.paypal.com/cgi-bin/webscr%3Fcmd%3D_xclick%26currency_code%3DUSD%26business%[email protected]%26amount%3D0.00%26item_name%3DJane+Doe+-+Invoice+6

 

Is there something wrong with the code snippet?  Any help is greatly appreciated.  Thank you.

 

Jesse

<?php 
$amount = number_format($row->total_with_tax - $row->amount_paid, 2, '.', '');
$link = "https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&currency_code=USD&business=".urlencode($companyInfo->primary_contact_email)."&amount=".urlencode($amount)."&item_name=".urlencode($row->name." - Invoice ".$row->invoice_number);
echo "<p>Pay the balance using PayPal - <a href='".$link."'>Click Here</a></p>";
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.