right now my php script is vulnerable to anyone putting in a random member_id into the url and having it excute sucessfully
how can I encrypt the id="id#" in the url, so a guest is unable to type in there own id in the posted id retrieved through the url?
echo "<td><a href='perfectrecords.php?id=" . $row->id . "'>Edit</a></td>";
<?php
function html_encode($var)
{
return htmlentities($var, ENT_QUOTES, 'UTF-8') ;
}
require_once('auth.php');
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>My interns</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
</head>
<body>
<h1> My Interns</h1>
<p><b>View All</b> | <a href="../Copy/view-paginated.php">View Paginated</a></p>
<?php
// connect to the database
include('../Copy/connect-db.php');
$var_id=$_SESSION['SESS_LOGIN'];
// get the records from the database
if ($result = $mysqli->query("SELECT * FROM `members`.`players` WHERE login='$var_id' "))
{
// display records if there are records to display
if ($result->num_rows > 0)
{
// display records in a table
echo "<table border='1' cellpadding='10'>";
// set table headers
echo "<tr><th>ID</th><th>Name</th><th>Description</th><th>Qualifications</th><th>login</th><th>hours</th><th>days required to work</th><th>pay</th><th>duties</th></tr>";
while ($row = $result->fetch_object())
{
// set up a row for each record
echo "<tr>";
echo "<td>" . $row->member_id . "</td>";
echo "<td>" . $row->name . "</td>";
echo "<td>" . $row->description . "</td>";
echo "<td>" . $row->qualifications . "</td>";
echo "<td>" . $row->login . "</td>";
echo "<td>" . $row->hours . "</td>";
echo "<td>" . $row->daysoftheweek . "</td>";
echo "<td>" . $row->pay . "</td>";
echo "<td>" . $row->duties . "</td>";
echo "<td>";
echo "<td><a href='perfectrecords.php?id=" . $row->id . "'>Edit</a></td>";
echo "<td><a href='delete.php?member_id=" . $row->id . "'>Delete</a></td>";
echo "</tr>";
}
echo "</table>";
}
// if there are no records in the database, display an alert message
else
{
echo "No results to display!";
}
}
// show an error if there is an issue with the database query
else
{
echo "Error: " . $mysqli->error;
}
// close database connection
$mysqli->close();
?>
<a href="../Copy/records.php">Add New Record</a>
</body>
</html>