Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 03/16/2024 in all areas

  1. A couple of things: A way to mitigate the potential for sql injection (even if this is a backoffice tool) would be to cast the company id parameter to integer. $id = (int)$_GET['COMPANY_ID']; See Danish's post to you for some helpful improvements. Indeed you should use bound parameters as shown. With that said, it's not relevant to your script not working. Also omit the ending tag in your php scripts. ( ?> ) . Just scanning the code provided, it seems likely there is an issue with the database connection on the production server. You didn't provide that code but you probably aren't catching connection errors in dataconn/connection.php
    1 point
  2. It seems like your code is vulnerable to SQL injection, which could be causing issues, especially when running on the web server. It's always essential to sanitize user inputs to prevent such vulnerabilities. <?php if (isset($_GET['COMPANY_ID'])) { include('dataconn/connection.php'); // Prepare an update statement $sql = "UPDATE `MASTER_COMPANY` SET `COMPANY_STATUS`=? WHERE `COMPANY_ID`=?"; // Attempt to prepare the SQL statement if ($stmt = mysqli_prepare($con, $sql)) { // Bind variables to the prepared statement as parameters mysqli_stmt_bind_param($stmt, "si", $PCompanySts, $id); // Set parameters $id = $_GET['COMPANY_ID']; $PCompanySts = "N"; // Attempt to execute the prepared statement if(mysqli_stmt_execute($stmt)) { session_start(); $_SESSION["delete"] = "Company Deleted Successfully!"; header("Location: /Companyindex.php"); exit(); } else { echo "Something went wrong"; } // Close statement mysqli_stmt_close($stmt); } else { echo "Error: Unable to prepare SQL statement."; } // Close connection mysqli_close($con); } else { echo "Company does not exist"; } ?> In this code: We're using prepared statements to safely execute the SQL query. User inputs are sanitized through parameter binding, reducing the risk of SQL injection. I've added exit() after the redirect header to ensure that no further code is executed after the redirection. Best Regard Danish Hafeez | QA Assistant ICTInnovations
    1 point
  3. Have you got php error reporting turned on? mysqli error reporting turned on? Have you checked error logs (on web server errors should be logged and not reported)?
    1 point
This leaderboard is set to New York/GMT-04:00
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.