Page 1 of 1

How do you execute a php file?

Posted: Sat Feb 11, 2012 5:53 am
by Philosophaie
I have a silly question. How do you execute a php file?

I tried with this:

<form action = "file.php" method = "post">
<input type="submit" name="submit" />
</form>

except I do not know how to coordinate the button event 'submit' with the start of the php file.

What code do I put at the beginning of the php file to initiate the input button 'submit' ?

Re: How do you execute a php file?

Posted: Sat Feb 11, 2012 7:16 am
by Celauran
Philosophaie wrote:What code do I put at the beginning of the php file to initiate the input button 'submit' ?
<?php

You don't have to do anything special. Clicking the submit button loads the PHP file via POST request and its contents are executed sequentially.

Re: How do you execute a php file?

Posted: Sat Feb 11, 2012 8:51 am
by Philosophaie
I tried to use the isset command at the beginning but it does not seem to be working:

Code: Select all

<?php
      if (isset($_POST['submit'])){
        echo 'Successful';
      } else {
        echo 'Unsuccessful';
      }
    ?>