数据库里有三个信息,w是超级管理员,权限是2,
j是管理员,权限是1,x是普通用户,权限是0。
判断登录的是超级管理员、管理员、还是用户的php代码怎么写呀,在setting 页面判断,判断后不同身份的角色登录后还要跳转到不同的页面,得用到include,图片是详细要求。希望代码尽量普通或者简单一些,太复杂的看不太懂,谢谢
php判断超级管理员,管理员,和用户的整段语句不会写
- 写回答
- 好问题 0 提建议
- 追加酬金
- 关注问题
- 邀请回答
-
2条回答 默认 最新
- |__WhoAmI__| 2022-12-15 16:50关注
<?php // Replace with your database server name, username, password, and database name $servername = ""; $username = ""; $password = ""; $dbname = ""; // Create a connection to the database $con = new mysqli($servername, $username, $password, $dbname); // Check if the connection was successful if ($con->connect_error) { die("Connection failed: " . $con->connect_error); } // Create the SQL query to create a table named "wjx1" $sql = "CREATE TABLE wjx1 ( id int(6) primary key, xuehao int(10), xingming varchar(30), password int(10), email varchar(30), denglucishu int(10), type int default '1' )"; // Execute the query and check if it was successful if ($con->query($sql) === true) { echo "Table wjx1 created successfully<br>"; } else { echo "Error creating table: " . $con->error . "<br>"; } // Insert some data into the table $sql = "INSERT INTO wjx1 (id, xuehao, xingming, password, email, denglucishu, type) VALUES (1, 2017, 'w', 2017, 'w00', 0, 2)"; // Execute the query and check if it was successful if ($con->query($sql) === true) { echo "Data inserted successfully<br>"; } else { echo "Error inserting data: " . $con->error . "<br>"; } // Insert more data into the table $sql = "INSERT INTO wjx1 (id, xuehao, xingming, password, email, denglucishu, type) VALUES (2, 2018, 'j', 2018, 'w00', 0, 1)"; // Execute the query and check if it was successful if ($con->query($sql) === true) { echo "Data inserted successfully<br>"; } else { echo "Error inserting data: " . $con->error . "<br>"; } // Insert more data into the table $sql = "INSERT INTO wjx1 (id, xuehao, xingming, password, email, denglucishu, type) VALUES (3, 2019, 'x', 2019, 'wjxo0', 0, 0)"; // Execute the query and check if it was successful if ($con->query($sql) === true) { echo "Data inserted successfully<br>"; } else { echo "Error inserting data: " . $con->error . "<br>"; } // Close the database connection $con->close(); ?>
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报
悬赏问题
- ¥15 linux驱动,linux应用,多线程
- ¥20 我要一个分身加定位两个功能的安卓app
- ¥15 基于FOC驱动器,如何实现卡丁车下坡无阻力的遛坡的效果
- ¥15 IAR程序莫名变量多重定义
- ¥15 (标签-UDP|关键词-client)
- ¥15 关于库卡officelite无法与虚拟机通讯的问题
- ¥15 目标检测项目无法读取视频
- ¥15 GEO datasets中基因芯片数据仅仅提供了normalized signal如何进行差异分析
- ¥100 求采集电商背景音乐的方法
- ¥15 数学建模竞赛求指导帮助