PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old November 18th, 2012, 06:19 PM
wouz wouz is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Posts: 107 wouz User rank is Sergeant Major (2000 - 5000 Reputation Level)wouz User rank is Sergeant Major (2000 - 5000 Reputation Level)wouz User rank is Sergeant Major (2000 - 5000 Reputation Level)wouz User rank is Sergeant Major (2000 - 5000 Reputation Level)wouz User rank is Sergeant Major (2000 - 5000 Reputation Level)wouz User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 19 h 51 m 14 sec
Reputation Power: 39
Using curl to submit a form in an iframe on another page?

I've got some sample codes of curl, but i think it won't work with what i'm trying to do. Before i waste hours of time I want to make sure it can be done, that's why im asking it here.

I am using an iframe with my affiliate ID in it for a site that searches available flights. The iframe shows a search box form. Hit submit and the flights show upin the same iframe.

Now, for my site, I want the search form on one page and the search results on another page. This can't be done because everything is in an iframe out of my control.

I thought of this way to do it:
- Copy the iframe's form html and put that on 'mypage A'.
- When someone fills the form and hits submit, it goes to 'mypage B' where there's the original iframe.
- When the user has hit 'submit' on mypage A, the values he filled in must be copied to the original form in the iframe in mypage B and submit it.

I never used curl but I thought, when mypage A form is submitted it goes to the curl page.
Here the values get echoed in the post string.
Then the curl page posts the data to the iframe page in mypage B.

Here my problems start. Since i want mypage B show the search results which are in an iframe, to what url do I let curl post to?
Also, the search form holds my affiliate ID, but the results page has no ID. So when i do find a way to show the search results in mypage B with this, curl posts the data directly to the result page, which doesn't hold my affiliate ID. I guess it's getting a cookie from the search form. But when the iframe search form gets skipped and curl directly posts to the results page, my affiliate ID is also skipped and possibly a cookie containing it too.

I thought I had the solution until i ran into these problems.
I wonder if there's a way to get the result I want but I'm starting to doubt it, so I hope the people here can tell me if this is even possible.
__________________
woozy.

Reply With Quote
  #2  
Old November 19th, 2012, 06:47 PM
E-Oreo's Avatar
E-Oreo E-Oreo is offline
Lost in code
Click here for more information.
 
Join Date: Dec 2004
Posts: 7,939 E-Oreo User rank is General 91st Grade (Above 100000 Reputation Level)E-Oreo User rank is General 91st Grade (Above 100000 Reputation Level)E-Oreo User rank is General 91st Grade (Above 100000 Reputation Level)E-Oreo User rank is General 91st Grade (Above 100000 Reputation Level)E-Oreo User rank is General 91st Grade (Above 100000 Reputation Level)E-Oreo User rank is General 91st Grade (Above 100000 Reputation Level)E-Oreo User rank is General 91st Grade (Above 100000 Reputation Level)E-Oreo User rank is General 91st Grade (Above 100000 Reputation Level)E-Oreo User rank is General 91st Grade (Above 100000 Reputation Level)E-Oreo User rank is General 91st Grade (Above 100000 Reputation Level)E-Oreo User rank is General 91st Grade (Above 100000 Reputation Level)E-Oreo User rank is General 91st Grade (Above 100000 Reputation Level)E-Oreo User rank is General 91st Grade (Above 100000 Reputation Level)E-Oreo User rank is General 91st Grade (Above 100000 Reputation Level)E-Oreo User rank is General 91st Grade (Above 100000 Reputation Level)E-Oreo User rank is General 91st Grade (Above 100000 Reputation Level)  Folding Points: 945 Folding Title: Novice Folder
Time spent in forums: 2 Months 9 h 13 m 20 sec
Reputation Power: 7053
cURL can't "post into an iframe", it runs on the server-side and has no concept of frames.

cURL can submit a request to whatever URL the original form's action attribute points at. This will return the HTML of the results page, which you could write out into your own page. If you want to display these results in an iframe, the src of the iframe has to point at your local script that contains the cURL code. You'll have to transfer the values the user entered into the iframe page using a session.

cURL will not copy cookies between the end-user and the remote site; that is not possible.

Quote:
Now, for my site, I want the search form on one page and the search results on another page. This can't be done because everything is in an iframe out of my control.

If you're able to copy and paste the HTML for the original form then you don't need cURL to do this. Just create three pages and put the form HTML on the first and third pages. Modify the first page to submit its form to the second page rather than the remote site. Put an iframe on the second page that points at the third page. Write JavaScript on the second page that injects the submitted values into the form that is sitting on the third page inside the iframe, then use JavaScript to submit the form. You'll lose the ability to modify/control the iframe at that point, but it sounds like that doesn't matter.

If you can't copy and paste the HTML for the original form, you'll need to use cURL on the third page to fetch a copy of the remote form.
__________________
PHP FAQ
How to program a basic, secure login system using PHP

Quote:
Originally Posted by Spad
Ah USB, the only rectangular connector where you have to make 3 attempts before you get it the right way around

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPHP Development > Using curl to submit a form in an iframe on another page?

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap