i'm student of PHP, and i build an app in android that save any data in Mysql BD, but i have problem with TIMESTAMP, that it saving date like 0000-00-00 00:00:00, below i attach my php code.
I tested with another php file, and the android app, send date correctly
PHP code
$db = new DbOperation();
$response = array();
if($_SERVER['REQUEST_METHOD']=='POST'){
//crear datos tabla registro
require 'php_tracker_server/conn.php';
registro();
//hecking the required params
if(isset($_POST['title']) and isset($_POST['message']) and isset($_POST['r_cel'])){
//creating a new push
$push = null;
//first check if the push has an image with it
if(isset($_POST['image'])){
$push = new Push(
$_POST['title'],
$_POST['message'],
$_POST['image']
);
}else{
//if the push don't have an image give null in place of image
$push = new Push(
$_POST['title'],
$_POST['message'],
null
);
}
//getting the push from push object
$mPushNotification = $push->getPush();
//getting the token from database object
$devicetoken = $db->getTokenByr_cel($_POST['r_cel']);
//creating firebase class object
$firebase = new Firebase();
//sending push notification and displaying result
echo $firebase->send($devicetoken, $mPushNotification);
}else{
$response['error']=true;
$response['message']='Parameters missing';
}
}else{
$response['error']=true;
$response['message']='Invalid request';
}
echo json_encode($response);
function registro() {
global $connect;
$cel = $_POST[ "r_cel" ];
$titulo = $_POST[ "title" ];
$fecha_r = $_POST[ "date" ];
$msj = $_POST[ "message" ];
//$query = "update escolar_tracker set latitude='$latitude',longitude='$longitude',date='$date',estado='$estado',speed='$speed' where ruta='$ruta' and jornada='$jornada'";
$query = "Insert into table1 (cel, titulo, fecha_r, msj) VALUES ('$cel','$titulo','$fecha_r','$msj')";
mysqli_query( $connect, $query )or die( mysqli_error( $connect ) );
mysqli_close( $connect );
}