gpt4 book ai didi

php - 插入查询有时不起作用

转载 作者:行者123 更新时间:2023-11-29 02:58:37 24 4
gpt4 key购买 nike

要插入数据库的 PHP 代码。该代码有时不起作用。大多数时候它确实有效。

<?php
include 'connection.php';
if (isset($_POST['docsignup']))
{

// prepare and bind
$stmt = $link->prepare("INSERT INTO doctor_details(firstname, lastname, license_num, zip_code, city, state, email, password, speciality) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)");
$stmt->bind_param("ssissssss", $docfname, $doclname, $docid, $doczipcode, $city, $state, $docemail, $hash, $speciality);

// set parameters and execute
$docfname = $_POST['docfname'];
$doclname = $_POST['doclname'];
$docemail = $_POST['docemail'];
$docloginpassword = $_POST['docloginpassword'];
$docid = $_POST['docId'];
$speciality = $_POST['speciality'];
$city = $_POST['city'];
$state = $_POST['state'];
$doczipcode = $_POST['doczipcode'];

// A higher "cost" is more secure but consumes more processing power
$cost = 10;

// Create a random salt
$salt = strtr(base64_encode(mcrypt_create_iv(16, MCRYPT_DEV_URANDOM)), '+', '.');

// Prefix information about the hash so PHP knows how to verify it later.
// "$2a$" Means we're using the Blowfish algorithm. The following two digits are the cost parameter.
$salt = sprintf("$2a$%02d$", $cost) . $salt;

// Value:
// $2a$10$eImiTXuWVxfM37uY4JANjQ==

// Hash the password with the salt
$hash = crypt($docloginpassword, $salt);

$stmt->execute();

echo "New records created successfully";

$stmt->close();
$link->close();

}
?>

连接.php

<?php
$link = mysqli_connect("localhost","root","","cl10-doctor");
?>

我注意到当我在密码字段中使用大写字母时代码不起作用。

我做错了吗?

最佳答案

不要区分大小写。让用户键入他/她想要的任何内容,但在后台将其转换为大写或小写。

密码以不可读的格式存储在数据库中,因此无论是大写还是小写都没有任何意义。

使用 php strtolower() 将密码转换为小写并将其存储在您的数据库中

在登录时重复上述操作。

关于php - 插入查询有时不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27330301/

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