Remove: Deprecated MySQLi functions - convert to OOP prepared statements
- create_bar_tab.php: Replaced mysqli_real_escape_string() and procedural mysqli_query/mysqli_num_rows/mysqli_error with OOP prepared statements - submit_order.php: Replaced mysqli_real_escape_string() and procedural mysqli_query/mysqli_error with OOP prepared statements - fetch_drinks.php: Replaced mysqli_real_escape_string() and procedural mysqli_query/mysqli_fetch_assoc with OOP prepared statements - comment_box.php: Removed mysqli_real_escape_string(), added CSRF token validation for comment submission All files now use consistent OOP MySQLi approach with proper parameter binding. Fixes PHP 8.1+ compatibility and improves security against multi-byte character injection.
This commit is contained in:
@@ -10,7 +10,13 @@ $conn = openDatabaseConnection();
|
||||
|
||||
// Handle comment post
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['submit_comment'])) {
|
||||
$comment = $conn->real_escape_string(trim($_POST['comment']));
|
||||
// Validate CSRF token
|
||||
if (!isset($_POST['csrf_token']) || !validateCSRFToken($_POST['csrf_token'])) {
|
||||
http_response_code(403);
|
||||
die('Security token validation failed.');
|
||||
}
|
||||
|
||||
$comment = trim($_POST['comment'] ?? '');
|
||||
|
||||
if (!empty($comment)) {
|
||||
$stmt = $conn->prepare("INSERT INTO comments (page_id, user_id, comment) VALUES (?, ?, ?)");
|
||||
|
||||
Reference in New Issue
Block a user