ausghostdog

Untitled

May 31st, 2012
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.53 KB | None | 0 0
  1. <?php
  2. if (!isset($_SESSION['loggedstaff']))
  3. {
  4. session_start();
  5. }
  6. require_once "../database/dbconn.php";
  7. require_once "../includes/functions.php";
  8. $condb = connect();
  9. $Product_code= $_POST['Product_code'];
  10. $Product_name= $_POST['Product_name'];
  11. $Product_descroption= $_POST['Product_descroption'];
  12. $Product_size= $_POST['Product_size'];
  13.  
  14. $Product_price= $_POST['Product_price'];
  15.  
  16.  
  17. if ($_FILES['filetoupload']["error"] > 0)
  18. {
  19. $error_message = mysqli_error($condb);
  20. include_once"adminnewproduct.php";
  21. }
  22. else if (file_exists(IMAGEFOLDER .$_FILES['filetoupload']['name']))
  23. {
  24. $error_message = mysqli_error($condb);
  25. /*include_once"adminnewproduct.php";*/
  26. }
  27.  
  28. else if (($_FILES["filetoupload"]['type'] == "image/gif") || ($_FILES["filetoupload"]['type'] == "image/jpeg") || ($_FILES["filetoupload"]['type'] == "image/png") )
  29. {
  30. move_uploaded_file($_FILES['filetoupload']['tmp_name'],IMAGEFOLDER.$_FILES['filetoupload']['name']);
  31. echo "file uploaded";
  32. $error_message = "";
  33. //validate data
  34. $error_message .= validate_product_code($Product_code);
  35.  
  36. if ($error_message != "")
  37. include_once "changeproduct.php";
  38. else
  39.  
  40.  
  41.  
  42. if (!isset($_POST['changeitem'])){
  43. $oQuery = mysqli_query($condb, "SELECT * FROM tblproducts WHERE Product_code = '$Product_code'");
  44. $oAssoc = mysqli_fetch_assoc($oQuery);
  45.  
  46. // run through form fields and check if they are blank
  47. if ($_POST['Product_code'] == ""){
  48. $_POST['Product_code'] = $oAssoc['Product_code'];
  49. };
  50.  
  51. if ($_POST['Product_name'] == ""){
  52. $_POST['Product_name'] = $oAssoc['Product_name'];
  53. };
  54.  
  55. if ($_POST['Product_descroption'] == ""){
  56. $_POST['Product_descroption'] = $oAssoc['Product_descroption'];
  57. };
  58.  
  59. if ($_POST['Product_size'] == ""){
  60. $_POST['Product_size'] = $oAssoc['Product_size'];
  61. };
  62.  
  63. if ($_POST['Product_price'] == ""){
  64. $_POST['Product_price'] = $oAssoc['Product_price'];
  65. };
  66. //here is image
  67. if ($_FILES['filetoupload']['name']== ""){
  68. $_FILES['filetoupload']['name'] = $oAssoc{$_FILES['filetoupload']['tmp_name']};
  69. };
  70.  
  71. $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']."'
  72. WHERE Product_code = '".$_POST['Product_code']."'");
  73. };
  74.  
  75. $result = mysqli_query($condb, $mysqli_query);
  76.  
  77. if ($result)
  78. {
  79. echo "product insert worked";
  80. }
  81. else
  82. {
  83. die (mysqli_error($condb));
  84. }
  85. header("Location: admincatalogue.php");
  86.  
  87. }
  88.  
  89.  
  90.  
  91. ?>
Advertisement
Add Comment
Please, Sign In to add comment