0

How would I use the post function to pass fields onto an IFrame? I am using the target label but it doesn't seem to work. What is supposed to happen is when I submit the fields, it posts the username and variable to a forum and logs me in. However, I am only being redirected to the login page instead. It might be helpful to know that the iframe is in a different file than the field.

     <form action="http://www.website.net/login.php" method="post" target="my_iframe">
        <label for="username">Username</label><input type="text" name="username" required>
        <label for="password">Password</label><input type="password" name="password" required>
        <input type="submit" name="login" value="Login" class="loginbtn"/><a href="http://www.website.net/register.php">Register</a>
      </form>

     <iframe name="my_iframe" src="http://www.website.net/forums/ucp.php?mode=login" frameborder="0" scrolling="auto" width="100%" height=1500px marginwidth="0" marginheight="5" ></iframe>
Robert Lu
  • 401
  • 1
  • 7
  • 15
  • possible duplicate [How do you post to an iframe?](http://stackoverflow.com/questions/168455/how-do-you-post-to-an-iframe) – Class Apr 05 '13 at 02:19
  • Yes, I've seen that post and I've followed its instructions but it is still not working. – Robert Lu Apr 05 '13 at 02:53

1 Answers1

1

Try that:

<form action="http://www.website.net/login.php" method="post" target="my_iframe">
        <label for="username">Username</label><input type="text" name="username" required>
        <label for="password">Password</label><input type="password" name="password" required>
        <input type="submit" name="login" value="Login" class="loginbtn"/><a href="http://www.website.net/register.php">Register</a>
      </form>

     <iframe name="my_iframe" src="http://www.website.net/forums/ucp.php?mode=login" frameborder="0" scrolling="auto" style="width:100%;height:1500px;margin: 5px 0;"></iframe>

You forgot to insert "" in the height iframe's property.

Remember to always use CSS then HTML proprerties, they are deprecated as per W3C HTML5/XHTML 1.0 rules.

  • Thanks for the reply. I removed the iframe and changed the forum header instead and everything is working fine. – Robert Lu Apr 06 '13 at 00:00