A JM Posted May 16, 2009 Share Posted May 16, 2009 I have a form that has a submit button that performs some function. The form itself also runs some scripting. Can someone tell me what the order of execution is when submitting a form? How is the php on my form executed - from top down sequentially? <form action="<?php echo $editFormAction; ?>" method="post" id="form1" enctype="multipart/form-data"> <input type="submit" name="submit" value="Enter Claim" /> Thanks, A JM, Quote Link to comment https://forums.phpfreaks.com/topic/158381-code-execution-question/ Share on other sites More sharing options...
PFMaBiSmAd Posted May 16, 2009 Share Posted May 16, 2009 Php code is executed on the web server at the time the page (form) is requested. Do a "view source" in your browser to see what you have in the browser. The action="...." parameter is the URL that the browser will submit the form data to. Quote Link to comment https://forums.phpfreaks.com/topic/158381-code-execution-question/#findComment-835247 Share on other sites More sharing options...
A JM Posted May 16, 2009 Author Share Posted May 16, 2009 The action="...." parameter is the URL that the browser will submit the form data to. I interpret that to mean the "action=" parameter will be executed first before any other code is executed? Quote Link to comment https://forums.phpfreaks.com/topic/158381-code-execution-question/#findComment-835253 Share on other sites More sharing options...
PFMaBiSmAd Posted May 16, 2009 Share Posted May 16, 2009 A parameter is not executed. It is a value that is used for some purpose. For a form in a browser its' purpose is to tell the browser the URL where to submit the form data. Quote Link to comment https://forums.phpfreaks.com/topic/158381-code-execution-question/#findComment-835256 Share on other sites More sharing options...
A JM Posted May 16, 2009 Author Share Posted May 16, 2009 I'm sorry I don't understand your reply. Since I'm new to PHP I don't know your terminology so layman's terms at the moment will help me understand. If I click the "Submit" button on my form what is the sequence of how the script is processed? Does this verify that "Submit" was pushed and then run the next line of code assuming it was true? isset($_POST['submit']) Quote Link to comment https://forums.phpfreaks.com/topic/158381-code-execution-question/#findComment-835423 Share on other sites More sharing options...
Daniel0 Posted May 16, 2009 Share Posted May 16, 2009 This is how it works (simplified): 1. User makes a request to the web server. 2. The web server hands over PHP files to PHP. 3. PHP interprets the code and hands it back to the web server. 4. The web server sends the response back to the user. When you submit your form, the user's browser sends another request to the URI specified in the <form>'s action attribute. The type of request is determined by the method attribute. The method can be either GET or POST, and the default is GET. Quote Link to comment https://forums.phpfreaks.com/topic/158381-code-execution-question/#findComment-835457 Share on other sites More sharing options...
A JM Posted May 17, 2009 Author Share Posted May 17, 2009 Ok, so at step #3 when it's reading the php does it read it from top to bottom, sequentially? Can you have multiple php tags in a single php document? Does it matter what order they are in? <?php ...code here ?> <?php ... code here ?> This checks if the submit button has been pushed/set correct? if( isset($_POST['submit'])){ If my code looked like the following how would the code be processed? <?php ... $editFormAction = $_SERVER['PHP_SELF'];... ...do something ?> <?php if( isset($_POST['submit'])){... ...do something ?> Quote Link to comment https://forums.phpfreaks.com/topic/158381-code-execution-question/#findComment-835924 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.