I've read this How can I run another PHP script using PHP? and some other sources.
so i have 2 files. testexec.php and testfile.php, the purpose of the testfile.php is to insert some query into table. the result running testexec.php is a success but no data inserted. i try accessing testfile.php directly and the data is inserted.
in testexec.php:
<?php
ignore_user_abort(true);
$pathFile = dirname(__FILE__) . "/textfile.php";
$cmd = "usr/bin/php " . $pathFile;
exec( $cmd , $output, $return);
if(!$return) {
echo "Fail";
} else {
echo "Success" . "<br/>";
}
?>
in testfile.php
<?php
include("database.php");
$myDB = new Database();
$dateTime = new DateTime();
$query = "INSERT INTO marking (description) VALUES ('Test Exec');";
$result = $myDB->insertMysqli($query);
if($result) {
echo "success";
} else {
echo "fail";
}
?>