因此,我正在PHP 5.6
的admin
面板功能和每當我嘗試將用戶切換到管理它將它們設置爲生成器我不知道在哪裏或我在做什麼錯 下面是代碼不知道爲什麼這不起作用(PHP)
這是updateusera.php
<?php include 'core/init.php';
$id = $_GET['id'];
$type = $_GET['type'];
if($type == 'admin'){
mysql_query("UPDATE `users` SET `type` = 'user' WHERE `user_id` = '$id'");
header('location: changeusers.php');
} else if($type =='user'){
mysql_query("UPDATE `users` SET `type` = 'admin' WHERE `user_id` = '$id'");
header('location: changeusers.php');
}
// ======================== =================================================
if($type == 'moderator'){
mysql_query("UPDATE `users` SET `type` = 'user' WHERE `user_id` = '$id'");
header('location: changeusers.php');
} else if($type =='user'){
mysql_query("UPDATE `users` SET `type` = 'moderator' WHERE `user_id` = '$id'");
header('location: changeusers.php');
}
// ============================================== ===========================
if($type == 'builder'){
mysql_query("UPDATE `users` SET `type` = 'user' WHERE `user_id` = '$id'");
header('location: changeusers.php');
} else if($type =='user'){
mysql_query("UPDATE `users` SET `type` = 'builder' WHERE `user_id` = '$id'");
header('location: changeusers.php');
}
?>
this is the changeusers.php file
由於某種原因,它不會讓我把兩個我在這裏PS碼我新的所以我仍然得到使用,以StackOverflow的這一切
如果任何人有一個想法,我很樂意聽到它
謝謝!
首先,你有兩個主要問題。 1.您正在使用不推薦使用的'mysql_ *'函數(自PHP 5.5起棄用,並在PHP 7中刪除)。 2. [SQL注入](http://php.net/manual/en/security.database.sql-injection.php)是開放的。我建議更改爲Mysqli或首選的PDO,然後使用Prepared Statements。 –
來自我的簡單問題。當你回聲$ _GET ['type']' – YVS1102
我得到了PHP的第一個使用,所以我正在建立這個更好的它,我也有很多其他文件,所以當我得到我將開始轉換爲mysqli – Darktornado23