Robert Lu
Robert Lu

Reputation: 473

Post an HTML Value to IFrame

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>

Upvotes: 0

Views: 702

Answers (1)

Matheus Loureiro
Matheus Loureiro

Reputation: 101

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.

Upvotes: 1

Related Questions