rwahdan1978 Posted Saturday at 12:51 PM Share Posted Saturday at 12:51 PM Him I have an OTP sysem where the user will enter the OTP that was sent to their email, in the DB it is saving the OTP and the expiry after 15 minutes. After they use it, I need to delete both from DB. I am able to set the number back to 0 since it is an integer. How to reset the dattime field to show 0000-00-00 00:00:00? $sqlUpdate = "UPDATE login_users SET otp_reset = 0, otp_expiry = ??? WHERE username_email = '$myusername'"; if(mysqli_query($db,$sqlUpdate)) { ..... } Quote Link to comment https://forums.phpfreaks.com/topic/327530-put-the-default-value-of-datetime/ Share on other sites More sharing options...
maxxd Posted Saturday at 02:26 PM Share Posted Saturday at 02:26 PM (edited) First off, don't inject variables directly into a query like that - use prepared statements. Secondly, if it's not too late already I recommend switching to the PDO database interface - it's much easier to work with and reason about. Now, as to your actual question, set the value to null. $qry = " UPDATE login_users SET otp_reset = 0 ,otp_expiry = :exp WHERE username_email = :email "; $sql = $pdoObject->prepare($qry); $result = $sql->execute($qry, [ 'exp' => null, 'email' => $myusername ]); Admittedly, I've been in the land of Laravel for about 5 years now and am not entirely sure of my syntax above, so take it with a grain of salt... Edited Saturday at 02:26 PM by maxxd Quote Link to comment https://forums.phpfreaks.com/topic/327530-put-the-default-value-of-datetime/#findComment-1653444 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.