Sorry if this has an answer elsewhere, this time I'm stumped on how to ask the question in a search engine.
I have a contact form that I re-use here and there, but I'm having a little trouble understanding its routing this time, owing to the location of the form.
Basically a php script in document_root includes various other php scripts from a subfolder; document_root/php (including header.php and footer.php). So, the 'root' script includes header.php, content.php and footer.php content.php has our form inside it which calls submit.php after js validation. The js validation script lives in the document_root/js folder
JS validation is fine, but once it's passed that, the JS script serialises that data and passes it to submit.php for more validation and sending. The problem is, when the php script responds (with errors or success), it doesn't make it's way back to the javascript, but instead builds a new html page.
From my limited knowledge, it seems the submit.php script is running under the context of the original 'root' script, so it doesn't make its way back to the javascript.
I guess this may be a little hard to help with, because I haven't included any code. I can do so if that would be necessary, but I'm hoping it's fairly obvious to someone who understands relativity in scripts.
As mentioned, this contact form usually works fine, it's just this time round, the form is one folder up from where it usually is.
Hope this is enough for someone to explain how these scripts run under different contexts. I'd love to nail this, as it seems to be a vital concept when it comes to scripting in php.
Thanks for looking.
Aucun commentaire:
Enregistrer un commentaire