Adding variables automatically to include order data in newsletter list/script/db

Hi,

I have a newsletter script that allows me to integrate it with my shopping cart, but it is not that easy…well not for me!

I want to add the name and email from the orders, which use the variables: $ordName and $ordEmail in the shopping cart, to the php script provided by newsletter script coder, but can’t figure out how.

Here is the script, I should use for integration, provided by the newsletter script coder:


<?
//RegisterProspect function will send all information to register.cgi
//Here is exaple of using this fuction
[B]//RegisterProspect('useremail@hotmail.com','John Doe');[/B]
function RegisterProspect($email,$name)
{

    $ordEmail=urlencode($email);
    $ordName=urlencode($name);
    $URL="http://www.mysite.com/cgi-bin/newsletter/register.cgi";
    $account=5;
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL,"$URL");
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS,
        "account=$account&email=$email&name=$name"
    );
    curl_exec ($ch);
    curl_close ($ch);
}
?>

[B]
I have made it work as a test by simply uncommenting the fourth line: “//RegisterProspect(‘useremail@hotmail.com’,‘John Doe’);” and the sample data was added to my newsletter list.

However, I don’t want to add “useremail@hotmail.com” and “John Doe” to my newsletter list since that was only a test with some samples. So, my questions are:[/B]

  • How can I grab the contents from the order itself knowing that the variables I am supposed to use are $ordName and $ordEmail ?
  • How could I transfer/add those order variables automatically to the function on the fourth line?

[B]
Thanks in advance!

SJ[/B]

In a page where $ordName and $ordEmail are in scope, you would call:

RegisterProspect($ordEmail, $ordName);

That is probably somewhere in the Shopping Cart code (on a page that is part of the Shopping Cart system)