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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T05:26:19+00:00 2026-06-18T05:26:19+00:00

I am creating a website when users can purchase products. I have created an

  • 0

I am creating a website when users can purchase products. I have created an admin side of this website and am trying to create a page where an admin, once logged in, can update the stock levels of a certain product on myphpadmin database. I have so far managed to get the code to a stage where it updates in my database but not to the selected product. Instead it creates a new record with the stock level and the price. I have carried the product ID from the previous page using the command below:

echo "<input type=hidden name=h_prodid value=".$stockid.">";

Therefore when the admin clicks on the update link they arrive at a page with the current details of that particular product. They then enter one or two values to update this particular product but currently a new record is inserted into the database, as opposed to updating the existing on. Please see the code below.

<?php

session_start();

include("db.php");

//create a variable called $pagename which contains the actual name of the page
$pagename="Product Update Confirmation";

//call in the style sheet called ystylesheet.css to format the page as defined in the style sheet
echo "<link rel=stylesheet type=text/css href=mystylesheet.css>";

//display window title
echo "<title>".$pagename."</title>";
//include head layout 
include("adminheadlayout.html");

//display the name of the site and the date dynamically. See uk.php.net
echo date ('l d F Y H:i:s');
echo "<p></p>";

include ("detectlogin.php");

//display name of the page
echo "<h2>".$pagename."</h2>";

//Capture the details entered in the form using the $_POST superglobal variable
//Store these details into a set of new variables
$newprice=$_POST['p_priceupdate'];
$newquantity=$_POST['p_quantityupdate'];
$prodid=$_POST['h_prodid'];

//If any of the variables is empty
if (!$newprice and !$newquantity)
{
echo "<br>Please enter a value for price and/or quantity ";
echo "<br>Go back to <a href=editstock.php>Edit Stock details</a>";
}
else
{
if (!$newprice or !$newquantity)
{
    //insert a new record in the order table to generate a new order number. 
    //store the id of the user who is placing the order as well as the current date and time
    $productupdateSQL="insert into Products (prodPrice, proQuantity, prodId)
    values ('".$newprice."', '".$newquantity."', '".$prodid."')";
    $exeproductupdateSQL=mysql_query($productupdateSQL);
    echo "<p strong>Stock level updated successfully!";
}

//if a database error is returned, display an order error message
else
{
echo "<p>Sorry there has been an error with your product update";
echo "Go back to <a href=editstock.php>Edit Stock Details</a>";
}
}
//include head layout
include("footlayout.html");
?>

Any ideas will be gratefully appreciated. I am nearly there however cannot find anything relating to this particular type of issue.

  • 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-18T05:26:20+00:00Added an answer on June 18, 2026 at 5:26 am

    Your script only contains an INSERT query, no UPDATE query, so it will never update existing records

    warning
    Your code is very insecure, uses outdated mysql_ functions and does not escape values at all. The code is therefore vulnerable for SQL Injection. SQL Injection may lead to exposing private data and data loss! Read about it here:
    http://www.unixwiz.net/techtips/sql-injection.html

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am creating a Ruby on Rails website. The users can have avatars from
I have been creating a website where my users can rate images that have
I'm creating a website in Ruby on Rails, where users can login using RESTful
I'm creating a website where users can write articles and comment on the articles.
I have a website where businesses can load items for sale. Then end users
I have been creating a website to allow users to rate an image uploaded
I setup my website to require unique email addresses (no two users can have
I'm creating a website element where users can contribute to a discussion. In doing
I am creating an website that will allow users too create there own blog/Content
I have a website and a facebook canvas app. Users on the website can

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.