How can I run php file from another php file with onclick button?
My first.php file:
echo "<form action='saveResult.php' method='post' name='Post'>";
echo "<input name='Save' type='submit' value='Save Result'> </p>";
I want to run 'saveResult.php' from my first.php without redirect to 'saveResult.php' page.
Thanks,
Edit 1: I try:
echo "<form action='' method='POST' name='Post'>";
echo "<input name='Save' type='submit' value='Save Result'>";
echo "</form>";
if(isset($_POST['Save'])){
require_once('saveResult.php'); // display error
include_once('saveResult.php'); // display error
include('saveResult.php'); // display error
}
The error is: HTTP Error 405.0 - Method Not Allowed The page you are looking for cannot be displayed because an invalid method (HTTP verb) is being used.
<form>-tag. And second,action=always redirect, even if its pointed to itself. If you dont want it, use jacascript withonclick-function on your button andajax-call.