Jump to content

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%3Dadmin@abc.com%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>";
?>

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.