Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions admin/chktitle.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php
require "functions/functions.php";
include ('functions/db_connect.php');
$image=$_GET['i'];
$chkimg="select from products where pro_image='$image'";
$run_title=mysqli_query($con,$chkimg);
$count=mysqli_num_rows($run_title);
if($count>0){
echo"Image already exist";
}
5 changes: 5 additions & 0 deletions admin/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.3.1/css/all.css">
<title>E-commerce Admin Panel</title>
<title>Admin Panel</title>
<style>
input[id="pro_price"]:invalid {
background-color: red;
}
</style>
</head>
<body>
<div class="wrapper">
Expand Down
34 changes: 29 additions & 5 deletions admin/insert_product.php
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<body>
<?php
if(!isset($_SESSION['user_email'])){
header('location: login.php?not_admin=You are not Admin!');
Expand All @@ -12,8 +13,11 @@
<div class="form-group row">
<label class="col-form-label col-sm-4 col-lg-3 d-none d-sm-block" for="pro_title">Product Title</label>
<div class="col-12 col-sm-8 col-lg-9">
<input class="form-control" type="text" id="pro_title" name="pro_title" placeholder="Title"
pattern="\w+" required>
<input class="form-control" type="text" id="pro_title" name="pro_title"
placeholder="Title">



</div>
</div>
<div class="form-group row">
Expand Down Expand Up @@ -53,13 +57,16 @@
<div class="form-group row">
<label class="col-form-label col-sm-4 col-lg-3 d-none d-sm-block" for="pro_image">Product Image</label>
<div class="col-12 col-sm-8 col-lg-9">
<input class="form-control-file" type="file" id="pro_image" name="pro_image" required>
<input onkeyup="chkimage(this.value)" class="form-control-file" type="file" id="pro_image" name="pro_image"
required>
<span id="image"></span>
</div>
</div>
<div class="form-group row">
<label class="col-form-label col-sm-4 col-lg-3 d-none d-sm-block" for="pro_price">Product Price</label>
<div class="col-12 col-sm-8 col-lg-9">
<input class="form-control" type="text" id="pro_price" name="pro_price" placeholder="Product Price">
<input class="form-control" type="text" id="pro_price" name="pro_price" placeholder="Product Price" required
pattern="[1-9][0-9]*">
</div>
</div>
<div class="form-group row">
Expand All @@ -83,6 +90,22 @@
</form>
</div>
</div>
<script>
function chkimage(proimg) {
if(proimg==''){
document.getElementById('image').innerText='';
}
else{
var http=new XMLHttpRequest();
http.onreadystatechange=function () {
if(http.readyState==4&&http.status==200){
document.getElementById('image').innerText=http.responseText;
}
}
http.open('get','chktitle.php?i='+proimg)
}
}
</script>
<?php
if(isset($_POST['insert_post'])){
//getting text data from the fields
Expand All @@ -106,4 +129,5 @@
}
}

?>
?>
</body>
2 changes: 2 additions & 0 deletions admin/login.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
}
header('location:index.php?logged_in=You have successfully logged in!');
}


}
?>
<!DOCTYPE html>
Expand Down
3 changes: 3 additions & 0 deletions admin/view_products.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
$count_pro = mysqli_num_rows($run_pro);
if($count_pro==0){
echo "<h2> No Product found in selected criteria </h2>";



}
else {
$i = 0;
Expand Down