I want to make a button that starts my php script after I click it. So do I just make 2 separate files and have action post to the php file and then let it start? or is there a better way to do this? Possibly in one document?
Update:
Well, I basically made a script that would do a series of a loops until it's finished. So usually when I visit the page it automatically starts, so I'm making a button to start it only when I need it.
More info: Answer to one of the questions, "starting the script" as in it would only execute the script.
More info: I really don't need to pass any data from the submit form to the php script. I just want my script to run when I hit a button. I just want to know what's the best way to do this.
Having 2 files like you suggested would be the easiest solution.
For instance:
(.. your html ..)
<form action="script.php" method="get">
<input type="submit" value="Run me now!">
</form>
(...)
<?php
echo "Hello world!"; // Your code here
?>
<?php
if (!empty($_GET['act'])) {
echo "Hello world!"; //Your code here
} else {
?>
(.. your html ..)
<form action="index.php" method="get">
<input type="hidden" name="act" value="run">
<input type="submit" value="Run me now!">
</form>
<?php
}
?>