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 8587499
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T22:35:03+00:00 2026-06-11T22:35:03+00:00

I am using one submit button to update data in a database and send

  • 0

I am using one submit button to update data in a database and send an email. However the data is not being saved to the database. The code looks like:

<?php
    if(isset($_POST['order_status']))
    {
    $dbhost = 'localhost';
    $dbuser = 'root';
    $dbpass = '';
    $conn = mysql_connect($dbhost, $dbuser, $dbpass);
    if(! $conn )
    {
    die('Could not connect: ' . mysql_error());
    }

    $orderno =$_POST['order_no'][$i];
    $status =$_POST['order_status'][$i];
    print_r($_POST['order_no']);
    $sql = 'UPDATE Orders SET status="' . $_POST['order_status'] . '" WHERE   Orderno="' .    $_POST['order_no'] . '"';

    mysql_select_db('PurchaseOrders');
    $retval = mysql_query( $sql, $conn );
    if(! $retval )
    {
    die('Could not update data: ' . mysql_error());
    }
    echo "Updated data successfully\n";
    mysql_close($conn);
    }
?>
<?php
    if(isset($_POST['order_selected']))
    {
    $keys = array_keys($_POST['order_selected']);

    foreach($keys as $key)
    {
        $to = $_POST['order_requested_by'][$key];
        $subject = "Order Form Approval";
        $message = "Your purchase order number: " . " " . $_POST['order_no'][$key] ."    ". "is" ." ". $_POST['order_status'][$key] ;
        $headers = "From: noreply@somewhere.com";
        $sent = mail($to, $subject, $message, $headers) ;
        if($sent)
        {header( 'Location: http://localhost/test/../' ) ; }
        else
        {print "We encountered an error sending your mail"; }
    }
}
?>

In my form the input fields look like this:

 echo '<td><input type="text" readonly=true name="order_supplier['.$i.']" value="' .    $row['Supplier'] . '"/></td>';
    echo '<td><input type="text" readonly=true name="order_total_price['.$i.']" value="' . $row['totalprice'] . '"/></td>';
    echo '<td><input type="text" readonly=true name="order_requested_by['.$i.']" value="' . $row['requestedby'] . '"/></td>';
    echo '<td>';
    echo '<select name="order_status['.$i.']" id="id" onchange="showUser(this.value)" >';
    echo '<option value = "Pending"   name="order_status['.$i.']" class = "pending"' . ($row['status'] == 'Pending' ? ' selected=selected' : '') . '>Pending</option>';
echo '<option value = "Approved"  name="order_status['.$i.']" class = "approved"' .     ($row['status'] == 'Approved' ? ' selected=selected' : '') . '>Approved</option>';
    echo '<option value = "Disapproved" name="order_status['.$i.']" class     ="disapproved"' . ($row['status'] == 'Disapproved' ? ' selected=selected' : '') . '>Disapproved</option>';
    echo '</select>';

I really do not know why this is breaking. When i click submit a message appears that the data has successfully been entered into the database. However no data is entered. Many Thanks

  • 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-06-11T22:35:04+00:00Added an answer on June 11, 2026 at 10:35 pm

    Well, Im surprised its not throwing an error..

    echo '<select name="order_status['.$i.']" id="id" onchange="showUser(this.value)" >
    

    says

    that $_POST['order_status'] is an array..

    So, I would suggest you echo out $sql, and I would imagine you will see why its not updated the record you thought.

    Im guessing it should read

    $sql = 'UPDATE Orders SET status="' .$status  '" WHERE   Orderno="' .$orderno ' . '"'; 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using .submit() method to send data. What I have is a question form
I am using mapreduce to run the program, to submit one job: I can
I am using one signal and slot connection in a block. My code as
When you move beyond using one instance for your database, what is the best
When I hit the submit button I want the entered data to appear in
I am using JEditable jquery plugin to update some data on my webpage. After
I'm trying to create a form using textarea and a submit button that will
I have form where before i was using simple post with <button name=submit id=register
When using one of the various JDBC template methods I am confused on how
Iam developing one application.In that iam using one uiimageview.And take another image view and

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.