数据库里有三个信息,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 RPA正常跑,cmd输入cookies跑不出来
- ¥15 求帮我调试一下freefem代码
- ¥15 matlab代码解决,怎么运行
- ¥15 R语言Rstudio突然无法启动
- ¥15 关于#matlab#的问题:提取2个图像的变量作为另外一个图像像元的移动量,计算新的位置创建新的图像并提取第二个图像的变量到新的图像
- ¥15 改算法,照着压缩包里边,参考其他代码封装的格式 写到main函数里
- ¥15 用windows做服务的同志有吗
- ¥60 求一个简单的网页(标签-安全|关键词-上传)
- ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法
- ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。