<?php //创建数据表user $servername="localhost"; $username="root"; $userpassword="123456"; $dbname = "testbook"; $connent=new mysqli($servername,$username,$userpassword,$dbname); if($connent->connect_error){ die("连接失败: " . $connent->connect_error); }else{ echo "连接成功"; } //创建表 原生的建表语句 id自增唯一 name age email $createtable="create table testuser ( user_id int(10) not null auto_increment primary key, user_name varchar(18) not null unique, user_psw varchar(32) not null, user_phone varchar(11) null, user_type tinyint(1) not null default 0, user_account float not null default 0 )"; if($connent->query($createtable)==true){//执行 echo "创建表testuser成功"; }else{ echo "Error creating table: " . $connent->error; }?>续写实现md5对密码进行加密
时间: 2024-03-29 22:37:38 浏览: 27
<?php
//创建数据表user
$servername="localhost";
$username="root";
$userpassword="123456";
$dbname = "testbook";
$connent=new mysqli($servername,$username,$userpassword,$dbname);
if($connent->connect_error){
die("连接失败: " . $connent->connect_error);
}else{
echo "连接成功";
}
//创建表 原生的建表语句 id自增唯一 name age email
$createtable="create table testuser (
user_id int(10) not null auto_increment primary key,
user_name varchar(18) not null unique,
user_psw varchar(32) not null,
user_phone varchar(11) null,
user_type tinyint(1) not null default 0,
user_account float not null default 0
)";
if($connent->query($createtable)==true){//执行
echo "创建表testuser成功";
}else{
echo "Error creating table: " . $connent->error;
}
// 对密码进行加密
$password = "123456";
$encrypted_password = md5($password);
?>
相关推荐
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![docx](https://img-home.csdnimg.cn/images/20210720083331.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
检查这段代码的错误并修改实现与bookshelf.php的跳转<?php //连接数据库 $servername = "127.0.0.12"; $username = "roots"; $password = "1234root"; $dbname = "zkw"; $conn = mysqli_connect($servername, $username, $password, $dbname); if (!$conn) { die("连接失败: " . mysqli_connect_error()); } //查询图书分类 $sql = "SELECT * FROM categories"; $result = mysqli_query($conn, $sql); mysqli_close($conn); //跳转到bookshelf.php页面 header("Location: bookshelf.php"); ?> <!DOCTYPE html> <html> <head> <title>图书分类</title> </head> <body> 图书分类 <?php while ($row = mysqli_fetch_assoc($result)) { ?> "><?php echo $row["name"]; ?> <?php } ?> </body> </html>
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)