This issue doesn’t seem to be apparent to me and I am struggling to understand why my php code can’t get the updateID required.
This is my update.php file
<h3> Update </h3>
<link href="css/signin.css" rel="stylesheet">
<body class="text-center">
<main class="form-signin">
<script src="javascript/features.js"></script>
<form action ="../includes/update.inc.php" method="post">
<input type="text" name="name" placeholder="Enter name of item...">
<input type="text" name="description" placeholder="Enter a description...">
<input type="number" name="quantity" min="1" placeholder="Enter quantity...">
<input type="number" name="price" min="1" step="any" placeholder="Enter price">
<button type="submit" name="update"> UPDATE </button>
<br>
</form>
<?php
include ("config.php");
if (isset($_SESSION["username"])){
if(!$_SESSION["is_admin"] == 1){
header("location: ../home.php");
}
}
if(isset($_POST['update'])){
$id = $_GET['updateid'];
$name = $_POST['name'];
$desc = $_POST['description'];
$quantity = $_POST['quantity'];
$price = $_POST['price'];
$sql ="UPDATE 'items' SET itemID = $id, name='$name', description='$desc', quantity='$quantity', price='$price'
WHERE itemID = $id";
$result = mysqli_query($conn, $sql);
if($result){
header("location: display.php");
}
else {
echo "Data not inserted";
}
}
For some reason it says that I cannot get the updateid as it is an undefined array key, yet in another file which displays the updateid in the browser through pressing a button.
<button><a href="../adminArea/update.php?updateid='.$itemid.'">Update</a></button>
Any help is appreciated