Still working on a simple web app, but am running into an issue where $_POST variables aren't pulling over.
edit.php:
<html>
<head>
<link rel="stylesheet" type="text/css" href="includes/styles.css" media="screen" />
<title>Inventory</title>
</head>
<body>
<?php
include 'includes/dbconnect.php';
$inven_id = $_GET['id'];
$query = "SELECT
*
FROM
inventory
INNER JOIN
products
ON
inventory.sku=products.sku
WHERE
inventory.id = '$inven_id'";
$result = mysqli_query($con,$query) or die(mysqli_error($con));
$row = mysqli_fetch_array($result);
mysqli_close($con);
?>
<form method="POST" action="submitchanges.php" />
<table>
<tr>
<td><input type="hidden" name="id" value="<?php echo $inven_id ?>" /></td>
</tr>
<tr>
<td><b>Species:</b></td>
<td><input type="text" name="species" value="<?php echo $row['name']; ?>" readonly="readonly" size="35" /></td>
</tr>
<tr>
<td><b>SKU:</b></td>
<td><input type="text" name="sku" value="<?php echo $row['sku']; ?>" readonly="readonly" size="35" /></td>
</tr>
<tr>
<td><b>Category:</b></td>
<td><input type="text" name="category" value="<?php echo $row['category']; ?>" readonly="readonly" size="35" /></td>
</tr>
<tr>
<td><b>Fry Count:</b></td>
<td><input type="text" name="frycount" value="<?php echo $row['quantityfry']; ?>" size="35" maxlength="4" /></td>
</tr>
<tr>
<td><b>Juvie Count:</b></td>
<td><input type="text" name="juviecount" value="<?php echo $row['quantityjuv']; ?>" size="35" maxlength="4" /></td>
</tr>
<tr>
<td><b>Adult Count:</b></td>
<td><input type="text" name="adultcount" value="<?php echo $row['quantityadult']; ?>" size="35" maxlength="4" /></td>
</tr>
<tr>
<td><b>Notes:</b></td>
<td><input type="text" name="notes" value="<?php echo $row['notes']; ?>" size="35" maxlength="255" /></td>
</tr>
<tr>
<td><b>Location:</b></td>
<td><input type="text" name="location" value="<?php echo $row['location']; ?>" size="35" /></td>
</tr>
<tr>
<td><b>Owner:</b></td>
<td><input type="text" name="owner" value="<?php echo $row['owner']; ?>" size="35" /></td>
</tr>
</table>
<input type="submit" name="submit" value="submit">
</form>
submitchanges.php:
<html>
<head>
<link rel="stylesheet" type="text/css" href="includes/styles.css" media="screen" />
<title>Inventory</title>
</head>
<body>
<?php
include 'includes/dbconnect.php';
$id = $_POST['id'];
$quantityfry = $_POST['frycount'];
$quantityjuv = $_POST['juviecount'];
$quantityadult = $_POST['adultcount'];
$notes = $_POST['notes'];
$location = $_POST['location'];
$owner = $_POST['owner'];
$query="UPDATE
inventory
SET
quantityfry = '$quantityfry',
quantityjuv = '$quantityjuv',
quantityadult = '$quantityadult',
notes = '$notes',
location = '$location',
owner = '$owner'
WHERE
id='$id'";
$result = mysqli_query($con,$query) or die(mysqli_error($con));
if ($result)
{
echo "Successful!";
echo "<BR>";
echo "<a href='index.php'>View result</a>";
}
else
{
echo "ERROR!";
}
mysqli_close($con);
?>
It seems some variables (the three quantity*) aren't pulling over properly. When I add this into my submitchanges.php, it doesn't display any output:
echo $_POST['quantityfry'];
echo $_POST['quantityjuv'];
echo $_POST['quantityadult'];
However, this does provide the expected output:
echo $_POST['notes'];
echo $_POST['location'];
echo $_POST['owner'];
What am I missing?
EDIT: PHP files updated to reflect discussed changes, and now they work as I want.