How to INSERT INTO a date ( NOW() ) with SQL in MySQL database with PHP Data Objects (PDO) in PHP

1 Answer

0 votes
try 
{
    $inserted = $con->prepare("INSERT INTO users(firstname, lastname, dateadd)
        VALUES(:firstname, :lastname", NOW());

    $inserted->execute(array(
        "firstname" => $_POST['firstname'],
        "lastname" => $_POST['lastname']
    ));
}
catch (PDOException $e) 
{
    die($e->getMessage());
}


answered May 27, 2015 by avibootz
edited Jul 7, 2015 by avibootz
...