HEX
Server: Apache
System: Linux b:u:marcbase:1 3.10.0-1160.31.1.el7.x86_64 #1 SMP Thu Jun 10 13:32:12 UTC 2021 x86_64
User: apache (92344)
PHP: 7.0.18
Disabled: apache_get_modules, apache_get_version, apache_reset_timeout, apache_getenv, apache_note, apache_setenv
Upload Files
File: /var/www/html/marcbase.com.br/web/android_connect/update_product.php
<?php

 

/*

 * Following code will update a product information

 * A product is identified by product id (pid)

 */

 

// array for JSON response

$response = array();

 

// check for required fields

if (isset($_POST['pid']) && isset($_POST['name']) && isset($_POST['price']) && isset($_POST['description'])) {

 

    $pid = $_POST['pid'];

    $name = $_POST['name'];

    $price = $_POST['price'];

    $description = $_POST['description'];

 

    // include db connect class

    require_once __DIR__ . '/db_connect.php';

 

    // connecting to db

    $db = new DB_CONNECT();

 

    // mysql update row with matched pid

    $result = mysql_query("UPDATE products SET name = '$name', price = '$price', description = '$description' WHERE pid = $pid");

 

    // check if row inserted or not

    if ($result) {

        // successfully updated

        $response["success"] = 1;

        $response["message"] = "Product successfully updated.";

 

        // echoing JSON response

        echo json_encode($response);

    } else {

 

    }

} else {

    // required field is missing

    $response["success"] = 0;

    $response["message"] = "Required field(s) is missing";

 

    // echoing JSON response

    echo json_encode($response);

}

?>