Solved

PHP Post iframe on load

Posted on 2014-04-09
7
253 Views
Last Modified: 2014-04-09
Hello,

I have the following code. I am trying to open a modal window with an iframe and have this data post to that page that it is going to load.

Can you please let me know how to make this work.

Thank you,
Matt

<?php
//where are we posting to?
$url = 'https://domain.com';

//what post fields?
$fields = array(
	'WPFNAME'=>$fname,				// First Name
	'WPLNAME'=>$lname,				// Last Name
	'WPEMAIL'=>$email,				// Email Address
	'WPHPHON'=>$phone,				// Phone Number (if on file)
	'WPADDR1'=>$saddress,			// Address
	'WPCITY'=>$city,				// City
	'WPSTATE'=>$state,				// State
	'WPZIP'=>$zip					// Zip
);

//build the urlencoded data
$postvars='';
$sep='';
foreach($fields as $key=>$value) 
{ 
   $postvars.= $sep.urlencode($key).'='.urlencode($value); 
   $sep='&'; 
}


//open connection
$ch = curl_init();

//set the url, number of POST vars, POST data
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch,CURLOPT_POST,count($fields));
curl_setopt($ch,CURLOPT_POSTFIELDS,$postvars);

//execute post
$result = curl_exec($ch);

//close connection
curl_close($ch);
?>

Open in new window

0
Comment
Question by:movieprodw
  • 4
  • 3
7 Comments
 
LVL 83

Expert Comment

by:Dave Baldwin
ID: 39989379
You can't POST to a page in a browser, you can only POST to a server.  Then the server would have to store the information.  Then it could put it in that page When the page is requested.  Then the problem becomes one of identifying which info goes with which page request.
0
 
LVL 1

Author Comment

by:movieprodw
ID: 39989429
Okay, thank you.

It is for a Loan app and I am not sure how to POST to the iframe but that is the requirement they have.

It is just name/address data so I have requested GET but not sure what they will say.

Thank you for the info.

Matt
0
 
LVL 83

Expert Comment

by:Dave Baldwin
ID: 39989462
Then just post to the URL that "they" gave you.  GET or POST doesn't matter, you can only send it to the server.  Still it would be the URL that "they" gave you.
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 1

Author Comment

by:movieprodw
ID: 39989489
Hello,

They said that I should just load my page in the iframe then POST to their page and link to it so the data populates.

Does that make sense?
0
 
LVL 83

Accepted Solution

by:
Dave Baldwin earned 500 total points
ID: 39989550
I'm not sure what 'link to it' means... but since it is their service, you probably need to follow their directions.  It's hard to second guess what they are doing since the details are not going to be visible.
0
 
LVL 1

Author Closing Comment

by:movieprodw
ID: 39989568
Thanks for talking it through with me
0
 
LVL 83

Expert Comment

by:Dave Baldwin
ID: 39989588
You're welcome, at least maybe their directions will make a little more sense now.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses four methods for overlaying images in a container on a web page
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
The viewer will learn how to count occurrences of each item in an array.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now