Jump to content

check whether submit button was pressed not working for iframe


RLJ

Recommended Posts

Hi, there is probably a straightforward solution to my problem, but I can't quite work it out. I use the following PHP line to check whether the submit button in an html form was pressed or not:

 

if (isset($_POST['buttonname'])==FALSE) 
{do something}

 

If the html form is contained within a PHP script as follows:

<?php
print"
<html>
<body>
<form action=check.php method=POST
//form here
</form>
</body>
</html>
";
?>

then the check works fine. But if the html form is contained within an external html file that is called upon in an iframe as follows:

<?php
print"
<html>
<body>
<iframe src ='form.htm'></iframe>
</body>
</html>
";
?>

then the check doesn't work and it always thinks the submit button wasn't pressed.

 

How can I perform this check when the submit button is in an external html file that is called upon in an iframe? Any help would be much appreciated! Thanks.

Link to comment
Share on other sites

you can't be sure what's going to happen if you don't use 100% valid HTML/FORM syntax. You need to close this tag, and you should always quote (or double-quote) tag variables:

 

<form action='check.php' method='post'>

 

and don't put spaces around the equal sign in tag values:

 

<iframe src='form.htm'></iframe>

 

if this doesn't fix things, please post the code that contains the submit button.

Link to comment
Share on other sites

Yeah sorry, had a few typos when posting my code, but that's not the problem.

 

form.htm (which contains the submit button) has the following structure:

 

<html>
<body>
<form action="check.php" method="POST">
<input type="submit" value="Next" name="buttonname">
</form>
</body>
</html>

 

check.php then contains:

if (isset($_POST['buttonname'])==FALSE)
{do something}

 

which works fine if I open form.htm directly and press the submit button (or if I put the code from form.htm inside a print command in a PHP script). However, if I call form.htm from inside an iframe as follows:

<?php
print"
<html>
<body>
<iframe src ='form.htm'></iframe>
</body>
</html>
";
?>

then, as I said, the check no longer works and it always thinks 'buttonname' hasn't been pressed.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.