Solved

PHP Post iframe on load

Posted on 2014-04-09
7
260 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Why Off-Site Backups Are The Only Way To Go

You are probably backing up your data—but how and where? Ransomware is on the rise and there are variants that specifically target backups. Read on to discover why off-site is the way to go.

 
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

Secure Your WordPress Site: 5 Essential Approaches

WordPress is the web's most popular CMS, but its dominance also makes it a target for attackers. Our eBook will show you how to:

Prevent costly exploits of core and plugin vulnerabilities
Repel automated attacks
Lock down your dashboard, secure your code, and protect your users

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…
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

729 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