사용자가 볼 수있는 내용 만 제한하려고합니다. URL 변수를 통해 PHP 변수를 전달하므로 자신의 정보만을 표시하지만 ID 번호를 편집하면 다른 사람의 정보를 볼 수 있습니까?PHP 변수로 제한 URL 입력
코드 나는 현재 여기에 표시되어있다 :
$managerID = preg_replace('#[^0-9]#i', '', $_SESSION["id"]);
$manager = preg_replace('#[^A-Za-z0-9]#i', '', $_SESSION["manager"]);
$password = preg_replace('#[^A-Za-z0-9]#i', '', $_SESSION["password"]);
include "../adminscripts/connect_to_mysql.php";
$sql = mysql_query("SELECT * FROM Users WHERE id='$managerID' AND username='$manager' AND password='$password' AND role='Student' LIMIT 1");
$existCount = mysql_num_rows($sql);
if ($existCount == 0) {
header("location: http://www.zuluirminger.com/SchoolAdmin/index.php");
exit();
}
?>
<?php
// Get a list of all items and display them in alphabetically
include "../adminscripts/connect_to_mysql.php";
//Check to see the URL variable exists in the database
$dynamicList = "";
if (isset($_GET['id'])) {
include "../adminscripts/connect_to_mysql.php";
$id = preg_replace('#[^0-9]#i', '', $_GET['id']);
***********************************************************************************
***********************************************************************************
// If the ID does not exist the display this message.
$sql = mysql_query("SELECT * FROM StudentAttendance WHERE StudentID='$id' ORDER BY AttendanceDate DESC");
$productCount = mysql_num_rows($sql);
if ($productCount > 0) {
while ($row = mysql_fetch_array($sql)) {
$AttendanceDate = $row["AttendanceDate"];
$AttendanceStatus = $row["AttendanceStatus"];
$Notes = $row["Notes"];
$dynamicList .= '<tr style="font-size:15px;">
<td>' . $AttendanceDate . '</td>
<td>' . $AttendanceStatus . '</td>
<td>' . $Notes . '</td>
</tr>';
}
} else {
$AttendanceDate = "nil";
$AttendanceStatus = "nil";
$Notes = "nil";
}
} else {
echo "Something is missing which means we can't display this page! Sorry for the inconvenience and please try again later!";
exit();
}
mysql_close();
?>
내가 퍼팅 시도 다음과 같은 경우 내가 위의 코드에 별표 (*)를 배치 한 곳에서 문 ...
if ($id != $managerID) {
$id = $managerID;
}
그러나 이건 작동하지 않는 것 같은데 ... 나는 그것을 올바른 장소에두고 있는가? 지금까지 올바른 변수를 사용했다고 말할 수 있습니까?
도움이 될 것입니다.
음 ... 그 별들은 모두 당신에게 어떤 이슈를 유발할 수 있습니다 ... – Neal
저는이 질문의 목적을 위해 그들을 넣었습니다 @Neal - 그들은 코드에 실제로 존재하지 않습니다 :) –
당신은 단지 암호화 할 수 있습니까/ID를 해독 하시겠습니까? – kevingreen