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 $method = "POST"; switch($method){ case "POST"; $user = json_decode(file_get_contents('php://input')); $sql = " SELECT null ,:name, :email, :mobile, :created_at"; $stm = $pdo->prepare($sql); $created_at = date('Y-M-D'); $stm->bindParam(':name', $user->name); $stm->bindParam(':email', $user->email); $stm->bindParam(':mobile', $user->mobile); $stm->bindParam(':created_at', $created_at); if($stm->execute()){ //error shows itself right here if it helps $response = ['status'=> 1 , 'message'=>'successful']; }else{ $response = ['status'=> 0 , 'message'=>'was NOT successful']; } echo json_encode($response); break; }
Copy Clear