How do you execute a php file?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Philosophaie
Forum Newbie
Posts: 2
Joined: Sat Feb 11, 2012 5:33 am

How do you execute a php file?

Post 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' ?
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: How do you execute a php file?

Post 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.
Philosophaie
Forum Newbie
Posts: 2
Joined: Sat Feb 11, 2012 5:33 am

Re: How do you execute a php file?

Post 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';
      }
    ?>
Post Reply