Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

PHP Post iframe on load

Posted on 2014-04-09
7
Medium Priority
?
264 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 84

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 84

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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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 84

Accepted Solution

by:
Dave Baldwin earned 2000 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 84

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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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
There are times when I have encountered the need to decompress a response from a PHP request. This is how it's done, but you must have control of the request and you can set the Accept-Encoding header.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
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…
Suggested Courses

604 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