Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- error_reporting(E_ALL);
- try {
- $pdo = new PDO('mysql:host=127.0.0.1;dbname=to_do_list', 'root', '');
- } catch (PDOException $e){
- echo $e->getMessage ();
- die('Could not connected');
- }
- $pdo->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION );
- $sql = "INSERT INTO tasks(title, due_date, description) VALUES (
- :title
- :due_date
- :description)";
- $stmt = $pdo->prepare($sql);
- if (!$stmt) {
- echo "\nPDO::errorInfo():\n";
- print_r($pdo->errorInfo());
- }
- $stmt->bindParam(':title', $_POST['title'], PDO::PARAM_STR);
- $stmt->bindParam(':due_date', $_POST['due_date'], PDO::PARAM_STR);
- $stmt->bindParam(':description', $_POST['description'], PDO::PARAM_STR);
- $stmt->execute();
- $result = $stmt->execute();
- var_dump($result)
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement