RLJ Posted December 2, 2010 Share Posted December 2, 2010 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. Quote Link to comment Share on other sites More sharing options...
BlueSkyIS Posted December 2, 2010 Share Posted December 2, 2010 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. Quote Link to comment Share on other sites More sharing options...
RLJ Posted December 2, 2010 Author Share Posted December 2, 2010 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. Quote Link to comment Share on other sites More sharing options...
RLJ Posted December 5, 2010 Author Share Posted December 5, 2010 Anyone? The problem only occurs when the html page containing the submit button is called inside an iframe. When opening the html page directly, as I said, the problem's not there. Thanks! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.