Is it possible to sent $_POST data from iframe to parent??

Discussion in 'PHP' started by 123GoToAndPlay, Mar 25, 2010.

  1. #1
    Hi all,

    I need a login form sitting in an iframe to $_POST the username/pwd to the parent window. But it seems the $_POST data is not being sent.

    i have tried this actions
    action="http://www.mydomain.com/login">
    Code (markup):
    and
    action="javascript:parent.parent_go_url('http://www.mydomain.com/login');"
    Code (markup):
    with this .js in the parent window
    function parent_go_url(url)
    	{
    		document.location=url;
    	}	
    Code (markup):
    any tips/suggesions/code examples
     
    123GoToAndPlay, Mar 25, 2010 IP
  2. pig2cat

    pig2cat Active Member

    Messages:
    299
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    60
    #2
    I'm not really sure, but maybe you can use the target attribute in the form. try and see what it does if you do target="_SELF" or target="_MAIN"
     
    pig2cat, Mar 25, 2010 IP
  3. 123GoToAndPlay

    123GoToAndPlay Peon

    Messages:
    669
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #3
    hmm, that didn't work.

    But thanks for thinking along
     
    123GoToAndPlay, Mar 25, 2010 IP
  4. danx10

    danx10 Peon

    Messages:
    1,179
    Likes Received:
    44
    Best Answers:
    2
    Trophy Points:
    0
    #4
    Can you post the form (everything from <form....</form>) from the external site (http://www.mydomain.com/login ?) - so I can help you better :)
     
    danx10, Mar 25, 2010 IP
  5. guardian999

    guardian999 Well-Known Member

    Messages:
    376
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    103
    #5
    Should it's possible.
    
    <form action="http://example.com/to/parent" method="post">
    <!-- Some form -->
    </form>
    
    PHP:
     
    guardian999, Mar 25, 2010 IP
  6. 123GoToAndPlay

    123GoToAndPlay Peon

    Messages:
    669
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #6
    @danx10, it isn't exactly an external site, but another part of my website. A part i develop with Codeigniter.

    The form redirects to the CI-controller but i doesn't login. I assume the $_POST values are lost.
    btw How can i check if anything is sent??

    Now this is the code in login_form_iframe.php. FYI this is the code from the iframe src
    
    
    <div id="contact-banner">some general info</div>
    <div id="login"><form id="login_form" target="_parent" method="post" action="javascript:parent.parent_go_url('mydomain.com/ci-controller/login');"><table height="34" cellspacing="0"><tr>
    <td>&nbsp;</td>
    <td>Username: <input name="usernamae" type="text" size="14"  maxlength="10" /></td>
    <td>&nbsp;&nbsp;Password: <input name="pwd" type="password" size="14"  maxlength="10" /></td>
    
    <td>&nbsp;&nbsp;<input type="submit" value="login" name="submit"/></td></tr>
    <tr>
    <td colspan=4>
    <div align="right">
    	<a href="javascript:parent.parent_go_url('mydomain.com/ci-controller/forgot-pwd/');">Forgot password</a> &nbsp; <a href="javascript:parent.parent_go_url('mydomain.com/ci-controller/register/');">Register</a>
    </div>
    </td>
    </tr>
    
    </table>
    </form></div>
    
    Code (markup):

    btw if i copy the code from the iframe without the parent.parent_go_url calls in the div it all works
    like
    
    
    <div id="contact-banner">some general info</div>
    <div id="login"><form id="login_form" target="_parent" method="post" action="'mydomain.com/ci-controller/login"><table height="34" cellspacing="0"><tr>
    <td>&nbsp;</td>
    <td>Username: <input name="usernamae" type="text" size="14"  maxlength="10" /></td>
    <td>&nbsp;&nbsp;Password: <input name="pwd" type="password" size="14"  maxlength="10" /></td>
    
    <td>&nbsp;&nbsp;<input type="submit" value="login" name="submit"/></td></tr>
    <tr>
    <td colspan=4>
    <div align="right">
    	<a href="mydomain.com/ci-controller/forgot-pwd/">Forgot password</a> &nbsp; <a href="mydomain.com/ci-controller/register/">Register</a>
    </div>
    </td>
    </tr>
    
    </table>
    </form></div>
    
    Code (markup):
    But i need to use an iframe to check an user status based on Codeigniter loggedin logic.


    regards
     
    Last edited: Mar 26, 2010
    123GoToAndPlay, Mar 26, 2010 IP
  7. stOK

    stOK Active Member

    Messages:
    114
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    53
    #7
    It's too clumsy explanation.
    I believe all you want may be achieved with ajax.
     
    stOK, Mar 26, 2010 IP
  8. extremalx

    extremalx Peon

    Messages:
    20
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #8
    very easy using jquery
     
    extremalx, Apr 3, 2010 IP