我正在尝试使用二进制字段来显示用户是否已确认那里的电子邮件地址。出于某种原因,它似乎总是设置为 30,这正常吗,你能告诉我为什么吗,谢谢。
PHP 代码
<?php
include 'php/base.php';
$status;
//setup some variables/arrays
$action = array();
$action['result'] = null;
$firstName = $_GET['firstname'];
$lastName = $_GET['lastname'];
$email = $_GET['email'];
$password = $_GET['password'];
$password = md5($password);
$add = mysqli_query($link,"INSERT INTO `users` VALUES(NULL,'$firstName','$lastName','$password','$email',1)");
if($add){
//the user was added to the database
//get the new user id
$userid = mysqli_insert_id($link);
//create a random key
$key = $firstName . $email . date('mY');
$key = md5($key);
//add confirm row
$confirm = mysqli_query($link,"INSERT INTO `confirm` VALUES(NULL,'$userid','$key','$email')");
if($confirm){
include 'php/functions.php';
//let's send the email
//include the swift class
include_once 'lib/swift_required.php';
//put info into an array to send to the function
$info = array(
'fname' => $firstName,
'email' => $email,
'key' => $key
);
//send the email
if(send_email($info)){
$status = "true" ;
}else{
$status = "false";
}
}
}
echo "true";
?>
PHP 我的管理员
最佳答案
您可能想使用 BIT数据类型或 bool 值。
二进制数据类型不适合存储 bool 值。
关于php - SQL 插入二进制设置为 30,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36113288/