A Submit button for a form located on my page triggers the code below, but I am unsure of how to save the numeric value of a textbox named 'amount' into a php variable which I can use in the below PDO query. I am unsure of the syntax. Thanks in advance!
if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form1")) {
$amount = isset($_POST['amount']) ? $_POST['amount'] : null;
if (null != $amount) {
$user = 'user';
$pass = 'pass';
$pdo = new PDO('mysql:host=localhost;dbname=dbname', $user, $pass);
session_start();
$tablename = $_SESSION['MM_Username'];
$UpdateQuery = sprintf('UPDATE `%s` SET `stock` = :amount WHERE `status` = 1', $tablename);
$stmt = $pdo->prepare($UpdateQuery);
$stmt->bindParam('amount', $amount);
$stmt->execute();
}
}
Removed db_select line and also have verified that the SESSION variable MM_Username is in fact set properly. Is there anyway SQL can spit back more detailed error reporting? When I run the code as it is above, I receive no errors, however, it simply does not work.