Solved

PHP Post iframe on load

Posted on 2014-04-09
7
252 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 82

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 82

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
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
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 82

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 82

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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Suggested Solutions

This article will explain how to display the first page of your Microsoft Word documents (e.g. .doc, .docx, etc...) as images in a web page programatically. I have scoured the web on a way to do this unsuccessfully. The goal is to produce something …
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
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.

760 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

18 Experts available now in Live!

Get 1:1 Help Now