Advertisement
Guest User

neveikiaaa

a guest
Jun 25th, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.62 KB | None | 0 0
  1. <?php
  2. error_reporting(E_ALL);
  3. try {
  4.     $pdo = new PDO('mysql:host=127.0.0.1;dbname=to_do_list', 'root', '');
  5.  
  6. } catch (PDOException $e){
  7. echo $e->getMessage ();
  8.     die('Could not connected');
  9. }
  10.  
  11.  
  12. $sql = "INSERT INTO tasks(id, user_id, title, description, created_at, updated_at, due_date) VALUES (
  13.            :title
  14.            :due_date )";
  15.  
  16. $stmt = $pdo->prepare($sql);
  17. if (!$stmt) {
  18.     echo "\nPDO::errorInfo():\n";
  19.     print_r($pdo->errorInfo());
  20. }
  21. $stmt->bindParam(':title', $_POST['title'], PDO::PARAM_STR);
  22. $stmt->bindParam(':due_date', $_POST['due_date'], PDO::PARAM_STR);
  23.  
  24. $stmt->execute();
  25.  
  26. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement