Nested (echoed) php running wrong script

Posted on 16th Feb 2014 by admin

Got a problem with a php website I'm creating.

In a nutshell, the first page is entirely html and calls a php script to process an uploaded file and some form fields using POST. After validating the uploaded file the script echos a new page with a new form containing hidden inputs to carry forward the extra information provided in the original form (this was easier than getting my head around cookies). It works, because when I view the generated source all of the hidden input values have been populated with the correct information.

The problem I am having is with the next part of the process - the echoed page includes a new button that is supposed to call a separate php script, using the new form values. But when the button is clicked, it executes the existing php script again (and fails on the validation) instead of running the correct script as referenced in the onClick attribute of the button.

Any idea what I'm doing wrong? or why it is behaving like this?

Other forums