Hi! Could we please enable some services and cookies to improve your experience and our website?

PHPize Online / SQLize Online  /  SQLtest Online

A A A
Login    Share code      Blog   FAQ

Online Sandbox for SQL and PHP: Write, Run, Test, and Share SQL Queries and PHP Code

Copy Format Clear

Stuck with a problem? Got Error? Ask AI support!

Copy Clear
Copy Format Clear
<?php $_POST['message'] = 'message'; if ($_SERVER['REQUEST_METHOD'] == 'POST') { header('content-type: application/json'); $output = array('success' => false); if (trim($_POST['message']) === '' || get_cookie_username() !== $admin_username) { echo json_encode($output); exit; } else { //this is a UTC datetime now. //$sql = "INSERT INTO admin_echo(message, created_on) values ('%s', UTC_TIMESTAMP())"; //maintaining compatibility with old portal $sql = "INSERT INTO admin_echo(message, created_on) values (:message , NOW())"; $stmt = $pdo->prepare($sql); $stmt->bindValue(':message', mg\Utils::clean($_POST['message'])); if ($stmt->execute()) { $output['success'] = true; echo json_encode($output); exit; } } } ?>
Copy Clear