catonthecouchproductions
asked on
Numerous redirects
I am working with a small API for lead capturing. I have this form: http://www.quickcash123.com/home-business.html
On submit, it will redirect to a url similar to this:
http://www.spinterface.com/system/generalAPI.php?paid=35<id=5&fname=Ryan&lname=Coughlin&address=399%20Saint%20Paul%20Street&city=Kennebunk&country=UnitedStates&state=AZ&zip=05402&phone=2075905241&besttime=08:48:50¤t_date=2010-04-21&IP=24.91.162.169&DateStamp=2010-04-21&email=ryan.coughlin@mymail.champlain.edu
That pages response then displays a URL that I then need to redirect the user too. BUT I can send parameters in this fashion:
https://www.businessinternetcoach.com/signup/index.php?p=35&dayphone=$phone&email=$email&fname=$fname&lname=$lname&address=$address&city=$city&state=$state&zip=$zip&country=$country
Once the form is submitted, send to the first URL posted, then redirect user will the data to the URL above.
My code is below that I am working with.
Maybe use AJAX? To send the data to the first server and on success redirect?
Ryan
On submit, it will redirect to a url similar to this:
http://www.spinterface.com/system/generalAPI.php?paid=35<id=5&fname=Ryan&lname=Coughlin&address=399%20Saint%20Paul%20Street&city=Kennebunk&country=UnitedStates&state=AZ&zip=05402&phone=2075905241&besttime=08:48:50¤t_date=2010-04-21&IP=24.91.162.169&DateStamp=2010-04-21&email=ryan.coughlin@mymail.champlain.edu
That pages response then displays a URL that I then need to redirect the user too. BUT I can send parameters in this fashion:
https://www.businessinternetcoach.com/signup/index.php?p=35&dayphone=$phone&email=$email&fname=$fname&lname=$lname&address=$address&city=$city&state=$state&zip=$zip&country=$country
Once the form is submitted, send to the first URL posted, then redirect user will the data to the URL above.
My code is below that I am working with.
Maybe use AJAX? To send the data to the first server and on success redirect?
Ryan
<?php
$name_first = $_POST['first_name'];
$name_last = $_POST['last_name'];
$Address = $_POST['Address'];
$Apt = $_POST['Apt'];
$City = $_POST['City'];
$state = $_POST['state'];
$email = $_POST['email'];
$zip = $_POST['zip'];
$phone_work_area = $_POST['phoneworkArea'];
$phone_work_prefix = $_POST['phoneworkPrefix'];
$phone_work_suffix = $_POST['phoneworkSuffix'];
$current_time = time();
$current_date = date("Y-m-d",$current_time);
$current_time = strftime("%H:%M:%S",$current_time);
$phone = $phone_work_area.$phone_work_prefix.$phone_work_suffix;
//Define option variables
$action = "http://www.spinterface.com/system/generalAPI.php?paid=35<id=5&fname=".$name_first."&lname=".$name_last."&address=".$Address."&city=".$City."&country=UnitedStates&state=".$state."&zip=".$zip."&phone=".$phone."&besttime=".$current_time."¤t_date=".$current_date."&IP=".$_SERVER['REMOTE_ADDR']."&DateStamp=".$current_date."&email=".$email;
//$cookie = "cookie".$admin[admin_id].".txt";
//echo $action ;
header('Location: '.$action.'');
// $agent = "Mozilla/5.0";
/*$referer = "http://www.traffic-clearing-house.com/Leadsdb/login.php"; */
//Initialize a CURL session
// $ch = curl_init($action);
//Define form data array
$postfields = array();
$postfields["name_first"] = urlencode($name_first);
$postfields["name_last"] = urlencode($name_last);
$postfields["Address"] = urlencode($Address);
$postfields["Apt"] = urlencode($Apt);
$postfields["City"] = urlencode($City);
$postfields["State"] = urlencode($state);
$postfields["zip"] = urlencode($zip);
$postfields["email"] = urlencode($email);
$postfields["phone"] = urlencode($phone);
$postfields["current_time"] = urlencode($current_time);
$postfields["current_date"] = urlencode($current_date);
// $postfields["__VIEWSTATE"] = urlencode($result);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $action );
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
//curl_setopt($ch, CURLOPT_HTTPHEADER, Array("Content-Type: text/xml"));
// curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $content);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
$result = curl_exec($ch);
//Set the CURL options
/* curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postfields);
//curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie);
//curl_setopt($ch, CURLOPT_USERAGENT, $agent);
//curl_setopt($ch, CURLOPT_REFERER, $referer);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_URL,$action);
//curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie);
$result = curl_exec($ch); */
echo $result;
?>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.