gpt4 book ai didi

php - Now() 未在注册时插入日期时间

转载 作者:行者123 更新时间:2023-11-29 00:28:37 25 4
gpt4 key购买 nike

正如标题所说..

这是我在 register.php 中的代码

if (empty($_POST) === false && empty($errors) === true) {
$register_data = array(
'username' => $_POST['username'],
'password' => $_POST['password'],
'first_name' => $_POST['first_name'],
'last_name' => $_POST['last_name'],
'signup' => 'now()',
'email' => $_POST['email'],
'email_code' => md5($_POST['username'] + microtime())
);

register_user($register_data);
header('Location: register.php?success');
exit();

这是我的用户函数文件中处理注册的部分。

function register_user($register_data) {
array_walk($register_data, 'array_sanitize');
$register_data['password'] = md5($register_data['password']);

$fields = '`' . implode('`, `', array_keys($register_data)) . '`';
$data = '\'' . implode('\', \'', $register_data) . '\'';

mysql_query("INSERT INTO `users` ($fields) VALUES ($data)");
email($register_data['email'], 'Activate your account', "Hello " . $register_data['first_name'] . ",\n\nYou need to activate your account, so use the link below:\n\nhttp://www.site.com/activate.php?email=" . $register_data['email'] . "&email_code=" . $register_data['email_code'] . "\n\n - admin");
}

如有任何提示,我们将不胜感激。

最佳答案

现在我已经查看了代码,正如我在评论中所说:您正在引用您的函数调用。 now() 是一个为您提供日期时间的函数调用; 'now()' 根本不是一种日期时间。您需要找到一种方法,在执行带分隔符的 implode 时,不将该特定字段与其他字段捆绑在一起。更好的是,使用更好的方式访问数据库:mysqli 或 PDO 都是更好的选择。

关于php - Now() 未在注册时插入日期时间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17692632/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com