有沒有什麼方法可以讓用戶在PHP中改變代碼的優勢?假設他們有我的網頁的完整源代碼。PHP可變黑客
// make the connection
$dbhost = 'localhost';
$dbuser = 'user';
$dbpass = 'password';
$db = "db";
$conn = new PDO("mysql:host=$dbhost;dbname=$db", $dbuser, $dbpass);
// set errors
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
// get the data
$stmt = $conn->prepare("select username from usernames where " . $number . " = '$session'");
$stmt->execute();
$row = $stmt->fetch();
$username = $row[0];
if ($username == "superuser") {
// code to view secure information and make changes to people accounts
}
有什麼辦法可以將他們的用戶名更改爲「超級用戶」?
我計劃能夠快速瀏覽和編輯人的帳戶詳細信息的安全代碼的一部分客戶的服務選擇,所以我不希望一些隨機的用戶能夠查看和編輯其他用戶的數據。
感謝
'$ number'和'$ session'設置在哪裏? – D4V1D
請嘗試在您的瀏覽器中使用例如按Ctrl-U。你看到PHP代碼嗎? –
請參閱http://stackoverflow.com/questions/60174/how-can-i-prevent-sql-injection-in-php?rq=1。您可以接受SQL注入。 – chris85