Must Insert!";
}
if (empty($message)) {
$error['message'] = " Must Insert!";
}
// common image file extensions
$allowedExts = array("gif", "jpeg", "jpg", "png");
// get image file extension
error_reporting(E_ERROR | E_PARSE);
$extension = end(explode(".", $_FILES["image"]["name"]));
if($image_error > 0) {
$error['image'] = " This field is required.";
} else if(!(($image_type == "image/gif") ||
($image_type == "image/jpeg") ||
($image_type == "image/jpg") ||
($image_type == "image/x-png") ||
($image_type == "image/png") ||
($image_type == "image/pjpeg")) &&
!(in_array($extension, $allowedExts))) {
$error['image'] = " Image type must jpg, jpeg, gif, or png!";
}
if (!empty($title) && !empty($message) && empty($error['image'])) {
$string = '0123456789';
$file = preg_replace("/\s+/", "_", $_FILES['image']['name']);
$function = new functions;
$image = $function->get_random_string($string, 4)."-".date("Y-m-d").".".$extension;
$upload = move_uploaded_file($_FILES['image']['tmp_name'], 'upload/notification/'.$image);
$upload_image = $image;
// insert new data to menu table
$sql_query = "INSERT INTO tbl_fcm_template (title, message, image, link) VALUES (?, ?, ?, ?)";
$stmt = $connect->stmt_init();
if ($stmt->prepare($sql_query)) {
// Bind your variables to replace the ?s
$stmt->bind_param('ssss', $title, $message, $upload_image, $link);
// Execute query
$stmt->execute();
// store result
$result = $stmt->store_result();
$stmt->close();
}
if($result) {
$succes =<<
alert('New Push Notification Template Added Successfully...');
window.location = 'push-notification.php';
EOF;
echo $succes;
} else {
$error['add_notification'] = "
Added Failed
";
}
}
}
?>
- Dashboard
- Notification
- Add New Notification Template