Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3282242
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T19:54:21+00:00 2026-05-17T19:54:21+00:00

A Submit button for a form located on my page triggers the code below,

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T19:54:22+00:00Added an answer on May 17, 2026 at 7:54 pm

    Edit: Totally revised answer with error reporting via Exception

    session_start();
    if (isset($_POST['MM_update']) && $_POST['MM_update'] == 'form1') {
        $amount = isset($_POST['amount']) ? $_POST['amount'] : null;
        if (null === $amount) {
            throw new Exception('Amount not set');
        }
        $user = 'user';
        $pass = 'pass';
        if (empty($_SESSION['MM_Username'])) {
            throw new Exception('Username table not set in session');
        }
        $pdo = new PDO('mysql:host=localhost;dbname=dbname', $user, $pass);
        $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
        $query = sprintf('UPDATE `%s` SET `stock` = :amount WHERE `status` = 1', $_SESSION['MM_Username']);
        $stmt = $pdo->prepare($query);
        $stmt->bindParam('amount', $amount);
        $stmt->execute();
    } else {
        echo 'Nothing to do';
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a form (AddNewCamper), which contains a textbox and a submit button. In
I need the value of submit button when form is posted in existing text
I have the following code: <button data-dojo-type=dijit.form.Button data-dojo-props='baseClass:styleButton' name=_action_update type=submit label=Save >Save</button> The problem
I created login from that when clicking submit button sends variables to login_success.php page.but
I have... a dynamic populated select box several input boxes a submit button form
I want to make preview button as usual form button next to submit button(as
I have a image button thats acts as a form submit button: <a href=#
I have tried to replace the submit button of a form with an ajax
I have a checkbox with id terms and a submit button in my form
I've been looking for a solution to disable the form submit button until the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.