I am making a website eCommerce website but I am stuck with this no-so working PHP and MySQL code,
Let's say, $_GET["pid"] is from URL sent from other page with given value of 111 and $_POST["submit"] is a Form's submit button from a same page.
<?php
$connection = mysqli_connect("localhost", "root", "", "users_database");
$row = mysqli_fetch_array(mysqli_query($connection, "SELECT * FROM users_products"));
if(isset($_POST["submit"])){
$pid = $_GET["pid"];
$sql_update = mysqli_query($connection, "UPDATE users_products SET product_name='$_POST[product_name]' WHERE id=$pid");
header("location: admin_home.php");
}
?>
The code will work if i change "WHERE id=$pid" to exact number such as "WHERE id=100". I believe there is a problem with the value "$pid" and needed to be change to other method?