<?php
class Baddriver{
// Constructor - open DB connection
function __construct() {
$this->db = new mysqli("localhost", "root", "password", "dbname");
$this->db->autocommit(FALSE);
}
// Destructor - close DB connection
function __destruct() {
$this->db->close();
}
// Main method to redeem a code
function bad() {
if(isset($_POST["plakano"]) || isset($_POST["secim"]) || isset($_POST["sehir"])){
$sehir=$_POST["sehir"];
$plakano=$_POST["plakano"];
$aciklama=$_POST["aciklama"];
$secim=$_POST["secim"];
$plaka = str_replace(",","",$plakano);
$stmt = $this->db->prepare("INSERT INTO veri (plakano,aciklama,tarih,sehir,secim) VALUES (?, ?, CURDATE(),?,?)");
$stmt->bind_param("ssss", $plakano,$aciklama,$sehir,$secim);
$stmt->execute();
$stmt->close();
$this->db->commit();
}
}
}
$api = new Baddriver;
$api->bad();
?>
This is my php file i search for 2 days now i understand 2 things first is i need to put
#!/usr/bin/php -q
at the top (honestly don’t know why) and i need to connect to my webserver open the shell and write the cron code like
PATH=/usr/local/sbin:/usr/local/bin:/home/user1/bin
MAILTO=user1@nowhere.org,user2@somewhere.org
0 2 1-10 * * du -h --max-depth=1 /
is it all than cron will work or something that i am missing? thanks for patiance and time.
#!/usr/bin/php -qtells your server that this script should be run with php.The cron code which you add to crontab will run your script at the specified intervals.
But that’s not all. Your script uses $_POST, but you cannot post to a PHP script if you run it as a cron job. So those values won’t be available.