Jump to content

cURL question


sixseven

Recommended Posts

Hi there,

 

I have a simple form online set up to email contact info and and some selections to an inbox. Simple enough. I now want the back end php code that emails me that info to also send my email marketing account the contact information. I was told to look into cURL, which I have been, and can't seem to figure it out.

 

I get all the field names and place them into variables. I was given the string in the variable $url to use in order to send the info to our email lists. I tried using the code below but it didn't work. I'm having a hard time understanding how to use cURL and was curious if anyone could shed some light.

 

Many thanks to anyone with answers.

 

 

$EmailFrom = Trim(stripslashes($_POST['fields_email'])); 
$FirstName = Trim(stripslashes($_POST['fields_fname'])); 
$LastName = Trim(stripslashes($_POST['fields_lname'])); 
$Street1 = Trim(stripslashes($_POST['fields_address1'])); 
$Street2 = Trim(stripslashes($_POST['fields_address2'])); 
$City = Trim(stripslashes($_POST['fields_city'])); 
$State = Trim(stripslashes($_POST['fields_state']));
$Zip = Trim(stripslashes($_POST['fields_zip']));  
$Country = Trim(stripslashes($_POST['fields_country'])); 


$url = "https://app.email.com/icp/signup.php?fields_email&fields_fname&fields_lname&fields_address1&fields_address2&fields_city&fields_state&fields_zip&fields_country&listid=XXXXXX&specialid:XXXXXX=SCCG&clientid=XXXXXX&formid=XXXX&reallistid=1&doubleopt=0&redirect=http://www.email.com/www/signup/thanks.html&errorredirect=http://www.email.com/www/signup/error.html";

$ch = curl_init();

curl_setopt($ch,CURLOPT_URL,$url);

$result = curl_exec($ch);

curl_close($ch);

Link to comment
Share on other sites

Hello!

 

Try this:

<?php

$some_var = trim( stripslashes( $_POST['some_var'] ) );
$some_var2 = trim ( stripslashes( $_POST['some_var2'] ) );

$url = "https://https.host.com/app.php?some_var={$some_var}&some_var2={$some_var2}";

$curl = curl_init();

curl_setopt($curl, CURLOPT_URL, $url);

curl_setopt ($curl, CURLOPT_RETURNTRANSFER, 1); // to return result into var

/* !!!IMPORTANT!!! do not verify ssl sertificate */
curl_setopt ($curl, CURLOPT_SSL_VERIFYPEER, 0); 
curl_setopt ($curl, CURLOPT_SSL_VERIFYHOST, 0);

/**
to send POST request:

curl_setopt ($curl, CURLOPT_POST, 1);

curl_setopt ($curl, CURLOPT_POSTFIELDS, "some_var={$some_var}&some_var2={$some_var2}"); // POST data

*/

$result = curl_exec ($curl);

echo htmlspecialchars($result); // Display result
?>

Link to comment
Share on other sites

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.