Jump to content

Recommended Posts

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,

Link to comment
https://forums.phpfreaks.com/topic/158381-code-execution-question/
Share on other sites

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.

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'])

 

 

 

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.

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
?>

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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