Notes
Notes - notes.io |
include '../../../database/catdb.php';
// include 'productheader.php';
?>
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<link rel="stylesheet" type="text/css" href="productstyle.css">
<body>
</body>
</html>
<?php
if(isset($_GET['pid']) && !empty($_GET['pid']))
{
$id = $_GET['pid'];
$stmt = $pdo->prepare("SELECT * FROM tbl_products WHERE pro_id = :id");
$stmt->bindParam(':id',$id);
$criteria =[
'id' => $_GET['pid']
];
$stmt->execute($criteria);
$user = $stmt->fetch();
// extract($user);
}
if(isset($_POST['update']))
{
// $id = $_GET['pid'];
$name = $_POST['txt_name'];
$price = $_POST['price'];
$description = $_POST['description'];
$procat = $_POST['product_cat'];
$images = $_FILES['txt_file']['name'];
$tmp_dir = $_FILES['txt_file']['tmp_name'];
$imageSize = $_FILES['txt_file']['size'];
$uploads_dir = '../../../../uploads/';
$imgExt=strtolower(pathinfo($images,PATHINFO_EXTENSION));
$valid_extensions=array('jpeg','jpg','png');
$pro_image=rand(1000, 1000000).".".$imgExt;
unlink($uploads_dir.$user['pro_image']);
move_uploaded_file($tmp_dir, $uploads_dir.$pro_image);
$stmt = $pdo->prepare('UPDATE tbl_products SET
pro_name=:name_up,
pro_image=:file_up,
price=:price_up,
description=:description_up,
product_categories =:procat_up
WHERE pro_id=:id');
$stmt->bindParam(':name_up',$name);
$stmt->bindParam(':file_up',$pro_image);
$stmt->bindParam(':price_up',$price);
$stmt->bindParam(':description_up',$description);
$stmt->bindParam(':procat_up',$procat);
$stmt->bindParam(':id',$id);
// unset($_POST['update']);
if($stmt->execute()){
header('location:productdisplay.php');
}else{
echo "Not inserted";
}
}
?>
<h2>Edit Product</h2>
<form method="post" action="editproduct.php?pid=<?php echo $user['pro_id'] ?>" enctype="multipart/form-data">
<input type="hidden" name="id" value="<?php echo $user['pro_id'] ?>">
<label>Name:</label><input type="text" name="txt_name" placeholder="Enter product name" value="<?php echo $user['pro_name'] ?>">
<label>File:</label><input type="file" name="txt_file" class="form-control" value="<?php echo $user['pro_image'] ?>">
<label>Price:</label><input type="text" name="price" maxlength="8" value="<?php echo $user['price'] ?>">
<label>Description:</label><textarea name="description"><?php echo $user['description'] ?></textarea>
<label>Category: </label>
<select name="product_cat">
<?php
$users = $pdo->prepare("SELECT * FROM tbl_cat");
$users->execute();
foreach ($users as $user) {
echo '<option value ="'.$user['cat_id'].'">'.$user['cat_name'].'</option>';
}
?>
</select>
<br><br>
<input type="submit" name="update" value="Update">
</form>
|
Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...
With notes.io;
- * You can take a note from anywhere and any device with internet connection.
- * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
- * You can quickly share your contents without website, blog and e-mail.
- * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
- * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.
Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.
Easy: Notes.io doesn’t require installation. Just write and share note!
Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )
Free: Notes.io works for 12 years and has been free since the day it was started.
You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;
Email: [email protected]
Twitter: http://twitter.com/notesio
Instagram: http://instagram.com/notes.io
Facebook: http://facebook.com/notesio
Regards;
Notes.io Team