I have this form and process page.
On a form page, there are two hidden inputs id and reg_time values set to null at the "end " when executing no problem with id but under the row reg_time I get 0000-00-00 00:00:00 timestamp set
in table users.
Any suggestions why?
function post($POST)
{
$POST = array_map('trim', $_POST);
$hash = "$2y$10$";
$salt = "nekiludistringzahash22";
$his = $hash . $salt;
$POST['pass'] = crypt($_POST['pass'],$his);
return $POST;
}
$sql = "insert into users values(:" . implode(",:", array_keys(post($_POST))) . ");";
try{
$db = new PDO('mysql:host=localhost;charset=utf8;dbname=dbname','root','');
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
}catch (PDOException $e)
{
die("Conn problem " . $e->getMessage());
}
$reg = $db->prepare($sql);
$reg->execute(post($_POST));
and form
<form action="exp2.php" method="post">
<input type="hidden" name="id" value="null">
<input type="text"name="uname">
<input type="text"name="pass">
<input type="text"name="name">
<input type="text"name="lname">
<input type="submit">
<input type="hidden" name="reg_time" value = "null">
</form>