Eliminacio de productes en beta + formulari per a penjar productes
This commit is contained in:
parent
74f3285dbd
commit
46067a8fa0
|
@ -0,0 +1,36 @@
|
|||
<?php
|
||||
include_once('parameters.php');
|
||||
$product_id = $_GET['product_id'];
|
||||
//========================================================================================================================================================
|
||||
// Guardem les dades de lusuari a la bdd
|
||||
|
||||
|
||||
if (true) {
|
||||
try {
|
||||
|
||||
$sql = $con->prepare("DELETE FROM bp_products WHERE bp_product_id = ?");
|
||||
$sql->bind_param('i', $product_id);
|
||||
$rs = $sql->execute();
|
||||
|
||||
if($rs) {
|
||||
$response['success'] = true;
|
||||
} else {
|
||||
$response['success'] = false;
|
||||
throw new Exception("Hi ha hagut un error al insertar el registre");
|
||||
}
|
||||
|
||||
|
||||
// if($rs) {
|
||||
// echo ("El registre ha estat satisfactori");
|
||||
// } else {
|
||||
// echo ("Hi ha hagut un error al insertar el registre");
|
||||
// }
|
||||
} catch( Exception $e ) {
|
||||
$response['message'] = $e->getMessage();
|
||||
}
|
||||
|
||||
echo json_encode($response);
|
||||
}
|
||||
header("Location: ./my-products.php");
|
||||
|
||||
?>
|
|
@ -0,0 +1,37 @@
|
|||
<?php
|
||||
include_once('parameters.php');
|
||||
$product_id = $_GET['product_id'];
|
||||
//========================================================================================================================================================
|
||||
// Guardem les dades de lusuari a la bdd
|
||||
|
||||
|
||||
if (false) {
|
||||
try {
|
||||
|
||||
$sql = $con->prepare("DELETE FROM bp_products WHERE bp_product_id = ?");
|
||||
$sql->bind_param('i', $product_id);
|
||||
$rs = $sql->execute();
|
||||
|
||||
if($rs) {
|
||||
$response['success'] = true;
|
||||
} else {
|
||||
$response['success'] = false;
|
||||
throw new Exception("Hi ha hagut un error al insertar el registre");
|
||||
}
|
||||
|
||||
|
||||
// if($rs) {
|
||||
// echo ("El registre ha estat satisfactori");
|
||||
// } else {
|
||||
// echo ("Hi ha hagut un error al insertar el registre");
|
||||
// }
|
||||
} catch( Exception $e ) {
|
||||
$response['message'] = $e->getMessage();
|
||||
}
|
||||
|
||||
echo json_encode($response);
|
||||
}
|
||||
header("Location: ./my-products.php");
|
||||
|
||||
|
||||
?>
|
18
header.php
18
header.php
|
@ -12,9 +12,21 @@
|
|||
<a href="home.php" class="w3-bar-item w3-button"><b>Botiga</b> php</a>
|
||||
<!-- Float links to the right. Hide them on small screens -->
|
||||
<div class="w3-right w3-hide-small">
|
||||
<a href="my-products.php" class="w3-bar-item w3-button">My Products</a>
|
||||
<a href="register-page.php" class="w3-bar-item w3-button">Register</a>
|
||||
<a href="login-page.php" class="w3-bar-item w3-button">Login</a>
|
||||
<?php
|
||||
session_start();
|
||||
if (isset($_SESSION['username'])) {
|
||||
echo('
|
||||
<a href="my-products.php" class="w3-bar-item w3-button">My Products 🗊</a>
|
||||
<a href="logout.php" class="w3-bar-item w3-button">Logout</a>
|
||||
');
|
||||
} else {
|
||||
echo('
|
||||
<a href="register-page.php" class="w3-bar-item w3-button">Register</a>
|
||||
<a href="login-page.php" class="w3-bar-item w3-button">Login</a>
|
||||
');
|
||||
}
|
||||
?>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
6
home.php
6
home.php
|
@ -6,9 +6,9 @@ include_once('parameters.php');
|
|||
<div class="w3-content w3-padding w3-margin-top" style="max-width:1564px;margin-top:32px">
|
||||
<!-- Header -->
|
||||
<header class="w3-display-container w3-content w3-wide" style="max-width:1500px;" id="home">
|
||||
<img class="w3-image" src="img/banner.jpg" alt="Botiga_php" width="1500" height="400">
|
||||
<img class="w3-image" src="img/banner.jpg" alt="Botiga_php" width="1500" height="250">
|
||||
<div class="w3-display-middle w3-margin-top w3-center">
|
||||
<h1 class="w3-xxlarge w3-text-white"><span class="w3-padding w3-black w3-opacity-min"><b>Botiga</b></span> <span class="w3-hide-small w3-text-light-grey">php</span></h1>
|
||||
<h1 class="w3-xxlarge w3-text-white"><span class="w3-padding w3-black w3-opacity-min"><b>Botiga</b></span> <span style="font-weight:bold" class="w3-hide-small w3-text-light-grey">php</span></h1>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
|
@ -62,7 +62,7 @@ include_once('parameters.php');
|
|||
<a href=\"./productDetail.php?bp_product_id=$bp_product_id\">
|
||||
<div class=\"w3-display-container\">
|
||||
<div class=\"w3-display-topleft w3-black w3-padding\">$bp_product_name</div>
|
||||
<div class=\"w3-display-bottomright w3-black w3-padding\">$bp_product_price €</div>
|
||||
<div class=\"w3-display-bottomright w3-black w3-padding\">" . number_format($bp_product_price,2,",",".") . " €</div>
|
||||
<img src=\"img/$bp_product_img_01\" alt=\"House\" style=\"width:100%\">
|
||||
</div>
|
||||
</a>
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 888 KiB |
Binary file not shown.
After Width: | Height: | Size: 112 KiB |
BIN
img/banner.jpg
BIN
img/banner.jpg
Binary file not shown.
Before Width: | Height: | Size: 112 KiB After Width: | Height: | Size: 395 KiB |
Binary file not shown.
After Width: | Height: | Size: 56 KiB |
|
@ -0,0 +1,41 @@
|
|||
<?php
|
||||
include_once('parameters.php');
|
||||
$username = $_POST['username'];
|
||||
$userpass = $_POST['userpass'];
|
||||
//========================================================================================================================================================
|
||||
// Guardem les dades de lusuari a la bdd
|
||||
|
||||
if (loginCheck($username, $userpass, $con)) {
|
||||
|
||||
session_start();
|
||||
$userData = userDetails($username, $con);
|
||||
$_SESSION['userid']=$userData['bp_user_id'];
|
||||
$_SESSION['username']=$userData['bp_user_name'];
|
||||
$_SESSION['useradddate']=$userData['bp_user_addDate'];
|
||||
|
||||
header("Location: ./my-products.php");
|
||||
|
||||
} else {
|
||||
header("Location: ./login-page.php?succes=0");
|
||||
}
|
||||
function loginCheck($username, $userpass, $con) {
|
||||
$sql = $con->prepare("SELECT bp_user_pass FROM bp_users WHERE bp_user_name = ?");
|
||||
$sql->bind_param("s", $username);
|
||||
$sql->execute();
|
||||
$sql->bind_result($encryptedUserpass);
|
||||
$sql->fetch();
|
||||
|
||||
return password_verify($userpass, $encryptedUserpass);
|
||||
}
|
||||
function userDetails($username, $con) {
|
||||
$sql = $con->prepare("SELECT bp_user_id, bp_user_name, bp_user_addDate FROM bp_users WHERE bp_user_name = ?");
|
||||
$sql->bind_param("s", $username);
|
||||
$sql->execute();
|
||||
$sql->bind_result($bp_user_id, $bp_user_name, $bp_user_addDate);
|
||||
$sql->fetch();
|
||||
|
||||
return (array("bp_user_id"=>$bp_user_id, "bp_user_name"=>$bp_user_name, "bp_user_addDate"=>$bp_user_addDate));
|
||||
|
||||
}
|
||||
|
||||
?>
|
12
login.php
12
login.php
|
@ -8,8 +8,10 @@
|
|||
if (loginCheck($username, $userpass, $con)) {
|
||||
|
||||
session_start();
|
||||
$_SESSION['userid']=userDetails($username, $con)['bp_user_id'];
|
||||
$_SESSION['username']=userDetails($username, $con)['bp_user_name'];
|
||||
$userData = userDetails($username, $con);
|
||||
$_SESSION['userid']=$userData['bp_user_id'];
|
||||
$_SESSION['username']=$userData['bp_user_name'];
|
||||
$_SESSION['useradddate']=$userData['bp_user_addDate'];
|
||||
|
||||
header("Location: ./my-products.php");
|
||||
|
||||
|
@ -26,13 +28,13 @@
|
|||
return password_verify($userpass, $encryptedUserpass);
|
||||
}
|
||||
function userDetails($username, $con) {
|
||||
$sql = $con->prepare("SELECT bp_user_id, bp_user_name FROM bp_users WHERE bp_user_name = ?");
|
||||
$sql = $con->prepare("SELECT bp_user_id, bp_user_name, bp_user_addDate FROM bp_users WHERE bp_user_name = ?");
|
||||
$sql->bind_param("s", $username);
|
||||
$sql->execute();
|
||||
$sql->bind_result($bp_user_id, $bp_user_name);
|
||||
$sql->bind_result($bp_user_id, $bp_user_name, $bp_user_addDate);
|
||||
$sql->fetch();
|
||||
|
||||
return (array("bp_user_id"=>$bp_user_id, "bp_user_name"=>$bp_user_name));
|
||||
return (array("bp_user_id"=>$bp_user_id, "bp_user_name"=>$bp_user_name, "bp_user_addDate"=>$bp_user_addDate));
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
<?php
|
||||
session_start();
|
||||
unset($_SESSION['username']);
|
||||
unset($_SESSION['userid']);
|
||||
|
||||
session_destroy();
|
||||
header("Location: ./home.php");
|
||||
?>
|
|
@ -5,8 +5,9 @@ session_start();
|
|||
if (!isset($_SESSION['username'])) {
|
||||
header("Location: ./home.php");
|
||||
}
|
||||
$userid = $_SESSION['userid'];
|
||||
$username = $_SESSION['username'];
|
||||
$userId = $_SESSION['userid'];
|
||||
$userName = $_SESSION['username'];
|
||||
$userAddDate = $_SESSION['useradddate'];
|
||||
|
||||
//FILTER BUTTON
|
||||
|
||||
|
@ -24,15 +25,46 @@ $username = $_SESSION['username'];
|
|||
|
||||
<div class="w3-content w3-padding w3-margin-top" style="max-width:1564px;margin-top:32px">
|
||||
<!-- Header -->
|
||||
<header class="w3-display-container w3-content w3-wide" style="max-width:1500px;" id="home">
|
||||
<img class="w3-image" src="img/banner.jpg" alt="Botiga_php" width="1500" height="400">
|
||||
<div class="w3-display-container w3-content w3-wide" style="max-width:1500px;" id="home">
|
||||
<img class="w3-image" src="img/banner.jpg" alt="Botiga_php" width="1500" height="250">
|
||||
<div class="w3-display-middle w3-margin-top w3-center">
|
||||
<h1 class="w3-xxlarge w3-text-white"><span class="w3-padding w3-black w3-opacity-min"><b>Botiga</b></span> <span class="w3-hide-small w3-text-light-grey">php</span></h1>
|
||||
<h1 class="w3-xxlarge w3-text-white"><span class="w3-padding w3-black w3-opacity-min"><b>Botiga</b></span> <span style="font-weight:bold" class="w3-hide-small w3-text-light-gray">php</span></h1>
|
||||
</div>
|
||||
</header>
|
||||
</div>
|
||||
|
||||
<div class="w3-container w3-padding-32" id="projects">
|
||||
<h3 class="w3-border-bottom w3-border-light-grey w3-padding-16"><?php echo $username . " "?>Products</h3>
|
||||
<div class="w3-container w3-row w3-border-bottom w3-border-light-grey w3-padding-32" id="projects">
|
||||
<div class="w3-container w3-col m3">
|
||||
<h3>My Products 🗊</h3>
|
||||
</div>
|
||||
<div class="w3-container w3-col m3">
|
||||
<h4>User: <?php echo $userName . " "?></h4>
|
||||
</div>
|
||||
<div class="w3-container w3-col m3">
|
||||
<h4>Account Creation: <?php echo $userAddDate . " "?></h4>
|
||||
</div>
|
||||
<div style="max-height:45px;max-width:270px;display:flex;justify-content:center;align-items: center;" onclick="document.getElementById('id01').style.display='block'" class="w3-button w3-black w3-col m3">
|
||||
<h4>Upload New Product ✚</h4>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Product uploader modal -->
|
||||
<div id="id01" class="w3-modal">
|
||||
<div class="w3-modal-content w3-animate-zoom">
|
||||
<header class="w3-container w3-black">
|
||||
<span onclick="document.getElementById('id01').style.display='none'"
|
||||
class="w3-button w3-display-topright">×</span>
|
||||
<h2>Upload New Product</h2>
|
||||
</header>
|
||||
<div class="w3-container">
|
||||
<form action="./insert-product.php">
|
||||
<div class="w3-container"><input class="w3-input w3-border" type="text" name="prodTitle" id="prodTitle" placeholder="Porduct Title.."></div><br>
|
||||
<div class="w3-container"><textarea class="w3-input w3-border" name="prodDescription" id="prodDescription" cols="30" rows="5" placeholder="Product Description.."></textarea></div><br>
|
||||
<div class="w3-container"><input class="w3-input w3-border" type="text" name="prodPrice" id="prodPrice" placeholder="Porduct Prce in Euros.."></div><br><br>
|
||||
<div class="w3-container"><input class="w3-button w3-black w3-display-bottommiddle" type="submit" value="Upload ⤒" onclick="document.getElementById('id01').style.display='none'"></div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="w3-container"><input type="submit" value="Upload ⤒" onclick="document.getElementById('id01').style.display='none'" class="w3-button w3-black w3-display-bottommiddle"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
|
@ -64,7 +96,7 @@ $username = $_SESSION['username'];
|
|||
|
||||
$sql = $con->prepare($sqlString);
|
||||
} else {
|
||||
$sqlString = "SELECT bp_product_id, bp_product_name, bp_product_price, bp_product_img_01 FROM bp_products WHERE bp_product_owner = $userid";
|
||||
$sqlString = "SELECT bp_product_id, bp_product_name, bp_product_price, bp_product_img_01 FROM bp_products WHERE bp_product_owner = $userId";
|
||||
|
||||
$sql = $con->prepare($sqlString);
|
||||
}
|
||||
|
@ -78,7 +110,7 @@ $username = $_SESSION['username'];
|
|||
<a href=\"./productDetail.php?bp_product_id=$bp_product_id\">
|
||||
<div class=\"w3-display-container\">
|
||||
<div class=\"w3-display-topleft w3-black w3-padding\">$bp_product_name</div>
|
||||
<div class=\"w3-display-bottomright w3-black w3-padding\">$bp_product_price €</div>
|
||||
<div class=\"w3-display-bottomright w3-black w3-padding\">" . number_format($bp_product_price,2,",",".") . " €</div>
|
||||
<img src=\"img/$bp_product_img_01\" alt=\"House\" style=\"width:100%\">
|
||||
</div>
|
||||
</a>
|
||||
|
|
|
@ -13,7 +13,7 @@ $sqlPString .= " FROM bp_products INNER JOIN bp_users WHERE bp_product_owner = b
|
|||
$sqlP = $con->prepare($sqlPString);
|
||||
$sqlP->bind_param("i", $product_id);
|
||||
$sqlP->execute();
|
||||
$sqlP->bind_result($product_name, $product_info, $broduct_price, $product_category, $product_img_01, $product_img_02, $product_img_03, $product_addDate, $product_owner_name);
|
||||
$sqlP->bind_result($product_name, $product_info, $product_price, $product_category, $product_img_01, $product_img_02, $product_img_03, $product_addDate, $product_owner_name);
|
||||
$sqlP->fetch();
|
||||
|
||||
|
||||
|
@ -27,7 +27,7 @@ $sqlP->fetch();
|
|||
<div class="w3-row">
|
||||
<?php
|
||||
echo ("
|
||||
<div class=\"w3-col m5\">
|
||||
<div class=\"w3-col m5 l4\">
|
||||
<div class=\"w3-content\" style=\"max-width:800px\">
|
||||
<img class=\"mySlides\" src=\"img/$product_img_01\" style=\"width:100%\">
|
||||
<img class=\"mySlides\" src=\"img/$product_img_02\" style=\"width:100%\">
|
||||
|
@ -45,22 +45,28 @@ $sqlP->fetch();
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<div class=\"w3-col m7 w3-padding\" style=\"max-height: 100vh; overflow: auto;\">
|
||||
<div class=\"w3-display-container\" style=\"height:100%;\">
|
||||
|
||||
<div class=\"w3-display-topleft\">
|
||||
<div class=\"\">
|
||||
<h2>$product_name</h2>
|
||||
<div class=\"w3-col m7 l8\" style=\"max-height: 500px;\">
|
||||
<div class=\"w3-margin-right w3-margin-left\">
|
||||
<div>
|
||||
<h2>$product_name</h2>
|
||||
</div>
|
||||
<div class=\"\">
|
||||
<div>
|
||||
<p>$product_info</p>
|
||||
</div>
|
||||
<div>
|
||||
<h2 style=font-weight:bold>" . number_format($product_price,2,",",".") . " €</h2>
|
||||
</div>
|
||||
<div>
|
||||
<p>Publisher: $product_owner_name</p>
|
||||
</div>
|
||||
|
||||
<div class=\"w3-display-bottomright w3-black w3-padding\">
|
||||
<div class=\"w3-button\"><a href=\"edit-product.php?product_id=$product_id\" class=\"w3-bar-item w3-button\">Edit</a></div>
|
||||
<div class=\"w3-button\"><a href=\"delete-product.php?product_id=$product_id\" class=\"w3-bar-item w3-button\">Delete</a></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class=\"w3-display-bottomright w3-black w3-padding\">
|
||||
<p>Publisher: $product_owner_name</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
");
|
||||
|
||||
|
|
|
@ -2,18 +2,10 @@
|
|||
include_once('header.php');
|
||||
include_once('parameters.php');
|
||||
|
||||
//FILTER BUTTON
|
||||
|
||||
// if (isset($_POST['submit'])) {
|
||||
// $uid = $_POST['uid'];
|
||||
// $date = $_POST['date'];
|
||||
|
||||
// $query = "SELECT * FROM uren WHERE DATUM(post_date)='$date'";
|
||||
// $respost = mysqli_query($mysqli, $query);
|
||||
// } else {
|
||||
// $query = "SELECT * FROM uren";
|
||||
// $respost = mysqli_query($mysqli, $query);
|
||||
// }
|
||||
session_start();
|
||||
if (!isset($_SESSION['username'])) {
|
||||
header("Location: ./home.php");
|
||||
}
|
||||
?>
|
||||
|
||||
<div class="w3-content w3-padding w3-margin-top" style="max-width:1564px;margin-top:32px">
|
||||
|
|
Loading…
Reference in New Issue