Solved

PHP Post iframe on load

Posted on 2014-04-09
7
256 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
Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

 
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

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

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

Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
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.

825 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