-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
211c78c
commit ddb245c
Showing
6 changed files
with
122 additions
and
18 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
|
||
<?php | ||
session_start(); | ||
if (isset($_GET['id']) ) { | ||
|
||
$pid = $_GET['id']; | ||
|
||
include_once "DB/DB_Connection.php"; | ||
$conn = DataBaseConnection(); | ||
|
||
$sql ="DELETE FROM `products` WHERE `Id` = $pid"; | ||
|
||
if($conn->query($sql)) | ||
{ | ||
$_SESSION['msg'] = "Product deleted from the system"; | ||
}else { | ||
$_SESSION['msg'] = "Failed to delete products: ".$conn->error; | ||
} | ||
header("location:../productRegistration.php"); | ||
} | ||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
|
||
|
||
<?php | ||
|
||
session_start(); | ||
|
||
if($_POST){ | ||
|
||
$pid = $_POST['pid']; | ||
$name = $_POST['name']; | ||
$price = $_POST['price']; | ||
$details = $_POST['details']; | ||
|
||
|
||
// echo($pid. $name. $price .$details); | ||
// exit; | ||
|
||
|
||
if (empty($name)) { | ||
$_SESSION['msg'] = "Please enter a Unique product name"; | ||
}else if(empty($price) || !is_numeric($price)){ | ||
$_SESSION['msg'] = "Please enter numeric price of the product"; | ||
}else if(empty($details)){ | ||
$_SESSION['msg'] = "Please enter product details"; | ||
}else if( strlen($details) > 300){ | ||
$_SESSION['msg'] = "Please enter product details in 300 words"; | ||
}else{ | ||
include_once "DB/DB_Connection.php"; | ||
$conn = DataBaseConnection(); | ||
|
||
$sql = "UPDATE `products` | ||
SET | ||
`name` = '$name', | ||
`price` = '$price', | ||
`details` = '$details' | ||
WHERE `Id` = '$pid'"; | ||
|
||
if($conn->query($sql)){ | ||
$_SESSION['msg'] = "Product updated successfully"; | ||
}else{ | ||
$_SESSION['msg'] = "Product to update the product:".$conn->error; | ||
} | ||
} | ||
header("location:../productRegistration.php"); | ||
} | ||
|
||
|
||
|
||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,10 +5,35 @@ | |
<!-- head --> | ||
<?php include_once"templating/head.php" ?> | ||
|
||
<?php if (!isset($_SESSION['loggedIn'])){ | ||
<?php | ||
if (!isset($_SESSION['loggedIn'])){ | ||
$_SESSION['msg'] = "Please login first"; | ||
header("location:login.php"); | ||
exit; | ||
} | ||
|
||
$pid = ''; | ||
$p_name = $p_price = $p_desc = ''; | ||
$script = 'Registration'; | ||
|
||
if (isset($_GET['id'])) { | ||
|
||
$pid = $_GET['id']; | ||
|
||
include_once "php/DB/DB_Connection.php"; | ||
$conn = DataBaseConnection(); | ||
|
||
$sql ="SELECT * FROM products WHERE Id = '$pid'"; | ||
$product = $conn->query($sql); | ||
|
||
foreach ($product AS $prd) { | ||
$p_name = $prd['name']; | ||
$p_price = $prd['price']; | ||
$p_desc = $prd['details']; | ||
$p_img = $prd['Image']; | ||
} | ||
$script = 'Update'; | ||
} | ||
?> | ||
|
||
<!-- Navigation --> | ||
|
@@ -22,21 +47,22 @@ | |
|
||
<div class="col-lg-6 bg-dark text-light mt-5 pb-5 pt-5"> | ||
|
||
<form action="php/productRegistrationCode.php" method="post" enctype="multipart/form-data"> | ||
<form action="php/product<?=$script?>Code.php" method="post" enctype="multipart/form-data"> | ||
<legend class="text-center text-uppercase">Product Registration</legend> | ||
<div class="form-group"> | ||
<input type="hidden" value="<?=$pid?>" name="pid"> | ||
<label for="name">Product Name :</label> | ||
<input type="text" name="name" id="name" class="form-control" placeholder="Example: John Doe" value=''> | ||
<input type="text" name="name" id="name" value="<?=$p_name?>" class="form-control" placeholder="Example: John Doe"> | ||
</div> | ||
|
||
<div class="form-group"> | ||
<label for="price">Product Price :</label> | ||
<input type="price" name="price" id="price" class="form-control" placeholder="Example: [email protected]"> | ||
<input type="price" name="price" id="price" value="<?=$p_price?>" class="form-control" placeholder="Example: [email protected]"> | ||
</div> | ||
|
||
<div class="form-group"> | ||
<label for="details">Product Details :</label> | ||
<textarea name="details" id="details" class="form-control" placeholder="Product Details ( In 300 words )"></textarea> | ||
<textarea name="details" id="details" class="form-control" placeholder="Product Details ( In 300 words )"><?=$p_desc?></textarea> | ||
</div> | ||
<div class="form-group"> | ||
<label for="details">Product image :</label><br> | ||
|
@@ -45,10 +71,13 @@ | |
<div class="form-group"> | ||
<input type="submit" class="form-control btn btn-success mt-4" value="SUBMIT"> | ||
</div> | ||
<p class="h4 text-center"><?php if (isset($_SESSION['msg'])) { | ||
<p class="h4 text-center"> | ||
<?php | ||
if (isset($_SESSION['msg'])) { | ||
echo($_SESSION['msg']); | ||
unset($_SESSION['msg']); | ||
} ?></p> | ||
} ?> | ||
</p> | ||
</form> | ||
|
||
</div> | ||
|
@@ -80,8 +109,8 @@ | |
<td><?=$row['details']?></td> | ||
<!-- <td>< ?=$row['image']?></td> --> | ||
<td class="d-flex justify-content-between"> | ||
<a class="btn btn-primary text-light" href="#"> EDIT </a> | ||
<a class="btn btn-danger text-light" href="#"> DELETE </a> | ||
<a class="btn btn-primary text-light" href="productRegistration.php?id=<?=$row['Id']?>"> EDIT </a> | ||
<a class="btn btn-danger text-light" href="php/deleteProduct.php?id=<?=$row['Id']?>"> DELETE </a> | ||
</td> | ||
</tr> | ||
<?php } ?> | ||
|