Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- include ('staff.php');
- ?>
- <?php
- include 'connectiondb.php';
- if (isset($_GET['id'])) {
- $targetID = $_GET['id'];
- $sql = mysql_query("SELECT * FROM products WHERE id='$targetID' LIMIT 1");
- $productCount = mysql_num_rows($sql); // count the output amount
- if ($productCount > 0) {
- while($row = mysql_fetch_array($sql)){
- $id=$row["id"];
- $prod_title = $row["pname"];
- $prod_category = $row["category"];
- $prod_desc = $row["description"];
- $price = $row["price"];
- $stock = $row["stock"];
- $ext = $row["ext"];
- $date_added = strftime("%b %d, %Y", strtotime($row["date_added"]));
- $temprod_title = $prod_title;
- $temprod_desc = $prod_desc;
- $temprice = $price;
- $temstock = $stock;
- $temext = $ext;
- echo'<tr>
- <table style="width:50%;">
- <tr>
- <td align="right"><h2><font color="darkgreen">Edit Product</font></h2></td>
- </tr>
- <td width="89" align="right" > <div><img src="uploads/'.$id.'.'.$ext.'" width="100" height="100" /></div></td>
- </tr>
- </table>';
- }
- } else {
- echo "<div id='error'>Invalid Id</div>";
- }
- }
- ?>
- <?php
- if (isset($_FILES['image']))
- {
- $pid = addslashes(strip_tags($_POST['id']));
- $prod_title = addslashes(strip_tags($_POST['prod_title']));
- $prod_desc = addslashes(strip_tags($_POST['prod_desc']));
- $price = addslashes(strip_tags($_POST['price']));
- $image_name = $_FILES['image']['name'];
- $image_size = $_FILES['image']['size'];
- $image_temp = $_FILES['image']['tmp_name'];
- $allowed_ext = array ('jpg', 'jpeg', 'png', 'gif');
- $image_ext = strtolower(pathinfo($image_name, PATHINFO_EXTENSION));
- $errors = array();
- $name = $_SESSION['username'];
- if ($image_name&&$prod_desc&&$prod_title&&$price&&$stock)
- {
- if (in_array($image_ext, $allowed_ext ) === false)
- {
- $errors[] = "<div id='error'>File type not allowed</div>";
- }
- if ($image_size > 9097152)
- {
- $errors[] = "<div id='error'>Maximum file size is 2mb</div>";
- }
- if (!empty($errors))
- {
- foreach ($errors as $error)
- {
- echo $error, '<br/>';
- }
- }
- else{
- unlink('uploads/'.$pid.'.'.$image_ext);
- unlink('uploads/thumbs/'.$pid.'.'.$image_ext);
- include ('inc/thumb.php');
- // include '../inc/connectdb.php';
- /*$sql = mysql_query("UPDATE products SET
- pname='$prod_title',description='$prod_desc',price='$price',ext='$image_ext'
- WHERE id='$pid'");*/
- $sql=mysql_query("SELECT * FROM products WHERE id='$pid'");
- while ($row = mysql_fetch_assoc($sql))
- {
- $pidfromprod=$row['id'];
- }
- mysql_query("INSERT INTO editproduct_request VALUES ('$pid','$prod_category','$prod_title','$prod_desc','$price','$image_ext',now(),'$temprod_title','$temprod_desc','$temprice','$temext','Pending','Pending','$name','Pending')");
- if ($image_name&&$image_size&&$image_temp!= "")
- {
- $image_file = "$pid".'.'.$image_ext;
- move_uploaded_file($image_temp, 'uploads/'.$image_file);
- create_thumb('uploads/', $image_file, 'uploads/thumbs/');
- echo "<script>alert('Request Sent to Admin!')</script>
- <script>location.href = 'staffeditrequest.php'</script> ";
- }
- }
- }
- else
- {
- echo "<div id='error'>Please fill in all fields</div>";
- }
- }
- ?>
- <font color="#FFF">
- <table style="width:100%;">
- <form action="" method="POST" enctype="multipart/form-data" >
- <tr>
- <td align="right">Change Image:</td>
- <td align="left"><input type="file" name="image" /></td>
- </tr>
- <tr>
- <td align="right">Product Name:</td>
- <td align="left"><input type="text" name="prod_title" value="<?php echo $prod_title; ?>"
- size="30"></td>
- </tr>
- <tr>
- <td align="right">Product Description:</td>
- <td align="left"><textarea name="prod_desc" cols="25" rows="10" id="comment"><?php echo
- $prod_desc; ?></textarea></td>
- </tr>
- <tr>
- <td align="right">Price:</td>
- <td align="left"><input type="text" name="price" value= "<?php echo $price; ?>"></td>
- </tr
- ><tr><td></td><td align="left">
- <input name="id" type="hidden" value="<?php echo $targetID; ?>" />
- <input type="submit" name="submit" value="Update products" style="font-family: verdana;border: 1px solid #1F79AE;
- background-color: #1F79AE;
- border-radius: 4px;
- box-shadow: inset 0 1px 3px #fff, inset 0 -15px #cbe6f2, 0 0 3px #8ec1da;
- -o-box-shadow: inset 0 1px 3px #fff, inset 0 -15px #cbe6f2, 0 0 3px #8ec1da;
- -webkit-box-shadow: inset 0 1px 3px #fff, inset 0 -15px #1F79AE, 0 0 3px #8ec1da;
- -moz-box-shadow: inset 0 1px 3px #fff, inset 0 -15px #cbe6f2, 0 0 3px #8ec1da;
- color: #336600;
- text-shadow: 0 1px #fff;
- padding: 2px 5px;" /></td></tr>
- <tr> <td></td><td align="right"></td></tr>
- </form>
- </table>
- </td>
- </tr>;
- <tr>
- </table>
- <html>
- <table height="300px">
- <td></td>
- </table>
- <table border=0 align="center" style="width:100%;">
- <td>
- <p style = "font-size:12px;text-align:left;font-color:black;">2013 © New Horizon Infinity Global Solutions, Inc. ALL Rights Reserved. Privacy Policy | Terms of Service </td>
- <td align="right"><font style="font-size: 12px;">Developed and Designed by Jaylord & Ron</td>
- </table>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement