Psst.. new poll here.
Psst.. new forums here.
Microsoft is blocking us again (TY IP Reputation!) so just use oauth login instead. :)
Paste
Pasted as PHP by name ( 9 years ago )
<!DOCTYPE html>
<html>
<head>
<title>Add Products</title>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" integrity="sha384-wvfXpqpZZVQGK6TAh5PVlGOfQNHSoD2xbE+QkPxCAFlNEevoEH3Sl0sibVcOQVnN" crossorigin="anonymous">
<style type="text/css">
.header {
text-align: center;
text-transform: uppercase;
color: #5cb85c;
padding-bottom: 10px;
}
</style>
</head>
<body>
<?php
require 'database-config.php';
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
if(isset($_POST["product_name"]) && isset($_POST["product_code"])&& isset($_POST["category"])&& isset($_POST["description"])){
$name = $_POST["product_name"];
$code = $_POST["product_code"];
$category = $_POST["category"];
$description = $_POST["description"];
// Upload
$target_dir = "img/";
$target_file = $target_dir .date("YmdHis"). basename($_FILES["fileToUpload"]["name"]);
move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file);
$sql = "INSERT INTO products (product_code, product_name, category, description, image) VALUES ('".$code."','".$name."','".$category."','".$description."','".$target_file."')";
$result = mysqli_query($conn, $sql);
if ($result) {
// echo "Add product successfully";
echo header("location: index.php");
die();
}else {
echo "Can not add product. Error: ".mysql_error($conn);
}
}else {
echo "Invalid product information";
}
}
?>
<form action="<?php echo $_SERVER['PHP_SELF'] ?>" method="POST" id="product-form" enctype="multipart/form-data">
<div class="container" xss=removed>
<input type="hidden" name="id" value="<?php echo $row["id"] ?>">
<div class="header">
<h2>Add Product</h2>
</div>
<div class="form-group">
<label for="name">Product Name</label>
<input type="text" class="form-control" name="product_name" id="name">
</div>
<div class="form-group">
<label for="code">Product Code</label>
<input type="text" class="form-control" name="product_code" id="code">
</div>
<div class="form-group">
<label for="category">Category</label>
<input type="text" class="form-control" name="category" id="category">
</div>
<div class="form-group">
<label for="description">Description</label>
<textarea class="form-control" name="description" id="description"></textarea>
</div>
<div class="form-group">
<label for="fileToUpload">Image</label>
<input type="file" name="fileToUpload" id="fileToUpload">
</div>
<button type="submit" class="btn btn-success" id="edit-btn" style="width: 100%">Add</button>
</div>
</form>
[removed][removed]
[removed][removed]
</body>
</html>
Revise this Paste