|
| 1 | +<?php |
| 2 | +header("Access-Control-Allow-Origin: *"); |
| 3 | +header("Content-Type: application/json; charset=UTF-8"); |
| 4 | +header("Access-Control-Max-Age: 3600"); |
| 5 | +header("Access-Control-Allow-Headers: Content-Type, Access-Control-Allow-Headers, Authorization, X-Requested-With"); |
| 6 | +header("Access-Control-Allow-Methods: POST"); |
| 7 | + |
| 8 | +$data = file_get_contents("php://input"); |
| 9 | +$data = json_decode($data); |
| 10 | + |
| 11 | +if(isset($data->text) ){ |
| 12 | + $username = "root"; |
| 13 | + $password = ""; |
| 14 | + $database = new PDO("mysql:host=localhost; dbname=codershiyar;charset=utf8;", $username, $password); |
| 15 | + |
| 16 | + $addData = $database->prepare("INSERT INTO course_release_date(text,time,date) VALUES(:text,CURRENT_TIME,CURRENT_DATE )"); |
| 17 | + $addData->bindParam("text",$data->text); |
| 18 | + |
| 19 | + if($addData->execute()){ |
| 20 | + print_r(json_encode(["message"=>"تم اضافة البيانات بنجاح "])); |
| 21 | + }else{ |
| 22 | + var_dump($addData->errorInfo()); |
| 23 | + print_r(json_encode(["error"=>"حدث خطا ما "])); |
| 24 | + } |
| 25 | + |
| 26 | +}else{ |
| 27 | + print_r(json_encode(["error"=>"حدث خطا ما "])); |
| 28 | +} |
| 29 | + |
| 30 | + |
| 31 | + |
| 32 | + |
0 commit comments