Jump to content

How do you call functions on an 'html submit' within same page?


soma56

Recommended Posts

I know how to redirect users using a simple form as a means of running a php script:

 

<form action="mynewpage.php" method="post">
Name: <input type="text" name="name" value="" />
    <br />
    <input type="submit" name="submit" value="Name" />
    </form>

 

However, what if I wanted to include everything on the same page? I know that the form action should be as follows:

 

<form action="" method="post">

 

Would I do a php include for the functions? If so, what's the best way (or any way for that matter) to call them when the user clicks the submit button?

<?php
if(isset($_POST['submit'] {
     // Do this stuff if the form has been submitted . . . can be functions, includes(), etc.
} else {
     // DO this other stuff if it hasn't been submitted . . .
}
?>
<form action="" method="POST">
. . .  form stuff here . . .
</form>

Archived

This topic is now archived and is closed to further replies.

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