Jump to content

PHP: How to check when a submit button is pressed from the Iframe form


halben

Recommended Posts

Hi,

 

I am hoping someone could please help/guide in the right direction.

 

I have a form in an iframe and I want to use PHP to check when the user has pressed the submit button in the iframe form. How would I approach on doing this?

 

 

 

Thanks,

Hal

 

 

You could put the form processing on the same page as your I frame source file.

 

Form here...

 

<input type="submit" value="Submit" name="submit"/> </form>

 

<?php if(isset($_POST['submit']) && ($_POST['submit'] == "Submit")) {

 

Page here...

If you have more than one submit button and want to know which one was pressed, you can give the buttons unique names and/or values and look at them. Or, you can use a hidden form field with a value unique to the form. Or, you can put a unique ?formID=foobar appended to the url of the form action url.

 

However, note that php cannot directly detect if a form button was pressed. php is parsed server-side. Button click events happen client-side. Even if you do one of the above methods, there is no guarantee that the user actually pressed that button. Some browsers allow for "Enter" to be pressed to invoke the click. Or, javascript could be used to invoke the submit. Or someone could write a script or use a program to otherwise programatically make a request to the script with relevant values.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.