Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- if (!isset($_SESSION['loggedstaff']))
- {
- session_start();
- }
- require_once "../database/dbconn.php";
- require_once "../includes/functions.php";
- $condb = connect();
- $Product_code= $_POST['Product_code'];
- $Product_name= $_POST['Product_name'];
- $Product_descroption= $_POST['Product_descroption'];
- $Product_size= $_POST['Product_size'];
- $Product_price= $_POST['Product_price'];
- if ($_FILES['filetoupload']["error"] > 0)
- {
- $error_message = mysqli_error($condb);
- include_once"adminnewproduct.php";
- }
- else if (file_exists(IMAGEFOLDER .$_FILES['filetoupload']['name']))
- {
- $error_message = mysqli_error($condb);
- /*include_once"adminnewproduct.php";*/
- }
- else if (($_FILES["filetoupload"]['type'] == "image/gif") || ($_FILES["filetoupload"]['type'] == "image/jpeg") || ($_FILES["filetoupload"]['type'] == "image/png") )
- {
- move_uploaded_file($_FILES['filetoupload']['tmp_name'],IMAGEFOLDER.$_FILES['filetoupload']['name']);
- echo "file uploaded";
- $error_message = "";
- //validate data
- $error_message .= validate_product_code($Product_code);
- if ($error_message != "")
- include_once "changeproduct.php";
- else
- if (!isset($_POST['changeitem'])){
- $oQuery = mysqli_query($condb, "SELECT * FROM tblproducts WHERE Product_code = '$Product_code'");
- $oAssoc = mysqli_fetch_assoc($oQuery);
- // run through form fields and check if they are blank
- if ($_POST['Product_code'] == ""){
- $_POST['Product_code'] = $oAssoc['Product_code'];
- };
- if ($_POST['Product_name'] == ""){
- $_POST['Product_name'] = $oAssoc['Product_name'];
- };
- if ($_POST['Product_descroption'] == ""){
- $_POST['Product_descroption'] = $oAssoc['Product_descroption'];
- };
- if ($_POST['Product_size'] == ""){
- $_POST['Product_size'] = $oAssoc['Product_size'];
- };
- if ($_POST['Product_price'] == ""){
- $_POST['Product_price'] = $oAssoc['Product_price'];
- };
- //here is image
- if ($_FILES['filetoupload']['name']== ""){
- $_FILES['filetoupload']['name'] = $oAssoc{$_FILES['filetoupload']['tmp_name']};
- };
- $mysqli_query= ("UPDATE tblproducts SET Product_name = '".$_POST['Product_name']."', Product_descroption = '".$_POST['Product_descroption']."',Product_size = '".$_POST['Product_size']."',Product_price = '".$_POST['Product_price']."', product_image = '".$_FILES['filetoupload']['name']."'
- WHERE Product_code = '".$_POST['Product_code']."'");
- };
- $result = mysqli_query($condb, $mysqli_query);
- if ($result)
- {
- echo "product insert worked";
- }
- else
- {
- die (mysqli_error($condb));
- }
- header("Location: admincatalogue.php");
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment