SitePoint Sponsor

User Tag List

Results 1 to 20 of 20
  1. #1
    SitePoint Addict
    Join Date
    Mar 2011
    Location
    Manchester, UK
    Posts
    227
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Get iframe Data?

    Hi Guys,

    I'm loading an iframe up which will display text saying like "data submitted". How do i get what comes up in the frame into a variable. For example.

    $iframe = iframedata

    Any help would be great.

    Thanks

    PS: Just donated 10 GBP to Cancer Research UK as a thank you for the continued support SitePoint users are giving me. Your help has not gone unnoticed.

  2. #2
    SitePoint Addict
    Join Date
    Mar 2011
    Location
    Manchester, UK
    Posts
    227
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I think this needs to be moved to the Javascript forum actually.
    You're Help Does Not Go Unnoticed, I have So Far Donated 25 GBP
    To Cancer Research UK As A Thank You To All The SitePoint
    Members That Have Helped Me In The PHP Forum Thank You!

  3. #3
    SitePoint Wizard bronze trophy chris.upjohn's Avatar
    Join Date
    Apr 2010
    Location
    Melbourne, AU
    Posts
    2,197
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    To the the contents of an <iframe> all you need is the page URL and a cool PHP function called file_get_contents(). See the below example for a reference on how to accomplish this...

    PHP Code:
    <?php

    $contents 
    file_get_contents('http://www.google.com');
    echo 
    $contents// Output the page contents

  4. #4
    SitePoint Addict
    Join Date
    Mar 2011
    Location
    Manchester, UK
    Posts
    227
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by SgtLegend View Post
    To the the contents of an <iframe> all you need is the page URL and a cool PHP function called file_get_contents(). See the below example for a reference on how to accomplish this...

    PHP Code:
    <?php

    $contents 
    file_get_contents('http://www.google.com');
    echo 
    $contents// Output the page contents
    Thanks for this, so will the page actually load as the URL i will be using will be submitting data through its URL, for example:

    domain.com/submit.php?name=scott&email=scot@gmail.com

    and so on. So will the page actually load and submit the data or just get the source code?

    Thanks
    You're Help Does Not Go Unnoticed, I have So Far Donated 25 GBP
    To Cancer Research UK As A Thank You To All The SitePoint
    Members That Have Helped Me In The PHP Forum Thank You!

  5. #5
    SitePoint Wizard rguy84's Avatar
    Join Date
    Sep 2005
    Location
    Durham, NC
    Posts
    1,659
    Mentioned
    5 Post(s)
    Tagged
    0 Thread(s)
    Ad, What are you trying to do generally?
    Ryan B | My Blog | Twitter

  6. #6
    SitePoint Addict
    Join Date
    Mar 2011
    Location
    Manchester, UK
    Posts
    227
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by rguy84 View Post
    Ad, What are you trying to do generally?
    We submit data to one of our partners through an iframe, when we submit the data through their URL (e.g domain.com/submit.php?name=scott&email=scot@gmail.com) it will say text like "Data Added To Database". What we need to do is grab that text and place it in a PHP Variable so we can add it do the database under the data we just submitted.

    e.g:

    Code:
    iframe loads www.domain.com/submit.php?name=scott&email=scot@gmail.com
    
    "Data Added To Database" is outputted on domain.com/submit.php?name=scott&email=scot@gmail.com
    
    $iframecontent = "Data Added To Database"
    Do you understand what im trying to do?

    Thank you.
    You're Help Does Not Go Unnoticed, I have So Far Donated 25 GBP
    To Cancer Research UK As A Thank You To All The SitePoint
    Members That Have Helped Me In The PHP Forum Thank You!

  7. #7
    SitePoint Wizard rguy84's Avatar
    Join Date
    Sep 2005
    Location
    Durham, NC
    Posts
    1,659
    Mentioned
    5 Post(s)
    Tagged
    0 Thread(s)
    so you run site a, but not site b. Site b holds a form that people enter data in, and site a wants the data from site b?
    Ryan B | My Blog | Twitter

  8. #8
    SitePoint Addict
    Join Date
    Mar 2011
    Location
    Manchester, UK
    Posts
    227
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by rguy84 View Post
    so you run site a, but not site b. Site b holds a form that people enter data in, and site a wants the data from site b?
    correct.
    You're Help Does Not Go Unnoticed, I have So Far Donated 25 GBP
    To Cancer Research UK As A Thank You To All The SitePoint
    Members That Have Helped Me In The PHP Forum Thank You!

  9. #9
    SitePoint Wizard rguy84's Avatar
    Join Date
    Sep 2005
    Location
    Durham, NC
    Posts
    1,659
    Mentioned
    5 Post(s)
    Tagged
    0 Thread(s)
    You would need to have somebody on site b code their page to e-mail you, add to your database, or however you want the data. An iframe points somewhere else, so you would need to control the page you link to.
    Ryan B | My Blog | Twitter

  10. #10
    SitePoint Addict
    Join Date
    Mar 2011
    Location
    Manchester, UK
    Posts
    227
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by rguy84 View Post
    You would need to have somebody on site b code their page to e-mail you, add to your database, or however you want the data. An iframe points somewhere else, so you would need to control the page you link to.
    This wont be possible, they wouldnt do it i know this already. Is there any type of code which can do what we need? (linux only).

    Thanks
    You're Help Does Not Go Unnoticed, I have So Far Donated 25 GBP
    To Cancer Research UK As A Thank You To All The SitePoint
    Members That Have Helped Me In The PHP Forum Thank You!

  11. #11
    SitePoint Wizard rguy84's Avatar
    Join Date
    Sep 2005
    Location
    Durham, NC
    Posts
    1,659
    Mentioned
    5 Post(s)
    Tagged
    0 Thread(s)
    Nope. I can rephrase your question so you can see the issue.

    I want to code a page so I can capture users login info when they attempt to login to [bank name]
    Ryan B | My Blog | Twitter

  12. #12
    SitePoint Wizard bronze trophy chris.upjohn's Avatar
    Join Date
    Apr 2010
    Location
    Melbourne, AU
    Posts
    2,197
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    Any URL in general should work in the file_get_contents() function.

  13. #13
    SitePoint Wizard rguy84's Avatar
    Join Date
    Sep 2005
    Location
    Durham, NC
    Posts
    1,659
    Mentioned
    5 Post(s)
    Tagged
    0 Thread(s)
    SL - he simply cant do what he's wanting to...
    Ryan B | My Blog | Twitter

  14. #14
    Keeper of the SFL StarLion's Avatar
    Join Date
    Feb 2006
    Location
    Atlanta, GA, USA
    Posts
    3,748
    Mentioned
    73 Post(s)
    Tagged
    0 Thread(s)
    Mmmh... not necessarily?

    While sort of in a grey-area type of enviroment, you could generate the form on your own site, capture the data, and pass it on to the other site's form. (Full disclosure would be morally required, naturally.)

  15. #15
    SitePoint Wizard rguy84's Avatar
    Join Date
    Sep 2005
    Location
    Durham, NC
    Posts
    1,659
    Mentioned
    5 Post(s)
    Tagged
    0 Thread(s)
    True StarLion. I assuming this was something like signup with our affliliates sort of deal, so making their own isn't possible.
    Ryan B | My Blog | Twitter

  16. #16
    SitePoint Addict
    Join Date
    Mar 2011
    Location
    Manchester, UK
    Posts
    227
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    We actually pass user registration data onto one of our clients which they pay us for, we just need to grab the output text when we pass the details onto them so we can see if the data was added to their database or not. Thats all I'm trying to do
    You're Help Does Not Go Unnoticed, I have So Far Donated 25 GBP
    To Cancer Research UK As A Thank You To All The SitePoint
    Members That Have Helped Me In The PHP Forum Thank You!

  17. #17
    Keeper of the SFL StarLion's Avatar
    Join Date
    Feb 2006
    Location
    Atlanta, GA, USA
    Posts
    3,748
    Mentioned
    73 Post(s)
    Tagged
    0 Thread(s)
    2 ways to do it;

    1. Duplicate the other site's HTML for the form, change the form handler to your own site. Catch the data yourself, do whatever you need to with it, and then use cURL to pass it to the client's form handler. Client gets their data, but the browser stays on your website.

    2. Duplicate the other site's HTML for the form, leave the form handler as the client's catcher. Add a javascript AJAX call to the form's onsubmit to catch the data, and return true to send the browser to the client's site with the data.

  18. #18
    SitePoint Addict
    Join Date
    Mar 2011
    Location
    Manchester, UK
    Posts
    227
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by StarLion View Post
    2 ways to do it;

    1. Duplicate the other site's HTML for the form, change the form handler to your own site. Catch the data yourself, do whatever you need to with it, and then use cURL to pass it to the client's form handler. Client gets their data, but the browser stays on your website.

    2. Duplicate the other site's HTML for the form, leave the form handler as the client's catcher. Add a javascript AJAX call to the form's onsubmit to catch the data, and return true to send the browser to the client's site with the data.
    There is no form though, we get the data passed onto us the same way we send it to our client.

    e.g domain.com/submit.php?name=scott&gender=male

    Doesnt matter iv got a guy doing the code for me, charging me $20 to do it and he said he was going to use cURL to do it.

    Thanks guys.
    You're Help Does Not Go Unnoticed, I have So Far Donated 25 GBP
    To Cancer Research UK As A Thank You To All The SitePoint
    Members That Have Helped Me In The PHP Forum Thank You!

  19. #19
    SitePoint Wizard rguy84's Avatar
    Join Date
    Sep 2005
    Location
    Durham, NC
    Posts
    1,659
    Mentioned
    5 Post(s)
    Tagged
    0 Thread(s)
    I assume that on submit that data is added to your database? If so, and they logically coded the form which lives on their site and you link to via iframe, the code should be like.
    PHP Code:
    <?php
      
    if( /*all data is valid*/ ){
       
    // add to your database
       // add to theirs
       
    echo "data submitted";
    } else { echo 
    "retry";}
    Ryan B | My Blog | Twitter

  20. #20
    Keeper of the SFL StarLion's Avatar
    Join Date
    Feb 2006
    Location
    Atlanta, GA, USA
    Posts
    3,748
    Mentioned
    73 Post(s)
    Tagged
    0 Thread(s)
    Ew. GET data passing. eww.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •