Current File : /home/users/kundensystem/www/admin/product_edit.php |
<?php
include './inc/header.php';
include './inc/sidebar.php';
if($adminRole['products']!='1'&&$adminData['role']!='1'){
?><script>location.href="index.php";</script><?php
exit;
}
if(!isset($_GET['id'])||$_GET['id']==''){?><script>location.href="./products.php";</script> <?php exit; }
$id=$_GET['id'];
$msg='';
if(isset($_POST['rand'])&&$_POST['rand']!=''&&$_POST['rand']==$_SESSION['rand']){
mysqli_query($conn, "UPDATE ".$dbtable12."
SET title = '".$_POST['title']."',
price = '".$_POST['price']."',
currency = '".$_POST['currency']."',
is_act = '".$_POST['is_act']."',
is_feature = '".$_POST['is_feature']."',
is_top = '".$_POST['is_top']."',
link = '".$_POST['link']."'
WHERE id = '".$id."'"
);
$sql=mysqli_query($conn, "SELECT * FROM ".$dbtable11);
while($point=mysqli_fetch_assoc($sql)){
mysqli_query($conn, "UPDATE ".$dbtable11."
SET card".$id." = '".(isset($_POST['point'.$point['id']]) ? '1' : '0')."'
WHERE id = '".$point['id']."'"
);
}
$msg='<div class="alert alert-success alert-dismissible fade show">Produkt wurde erfolgreich geändert!</div>';
}
$sql=mysqli_query($conn, "SELECT * FROM ".$dbtable12." WHERE id='".$id."'");
$product=mysqli_fetch_assoc($sql);
if(!$product){ ?><script>location.href="./products.php";</script> <?php exit; }
?>
<main id="main" class="main">
<div class="pagetitle">
<h1>Produkt bearbeiten</h1>
<nav>
<ol class="breadcrumb">
<li class="breadcrumb-item"><a href="index.php">Home</a></li>
<li class="breadcrumb-item">Unsere Produkte</li>
<li class="breadcrumb-item">Produkt bearbeiten</li>
</ol>
</nav>
</div><!-- End Page Title -->
<section class="section dashboard">
<div class="row">
<div class="col-lg-2"> </div>
<div class="col-lg-8">
<div class="card">
<div class="card-body">
<h5 class="card-title">Produkt bearbeiten</h5>
<?= $msg;?>
<form method="post">
<div class="mb-3 row">
<label class="col-lg-3 col-form-label text-right">Titel : </label>
<div class="col-lg-4">
<input type="text" class="form-control" name="title" value="<?= $product['title'];?>">
</div>
</div>
<div class="mb-3 row">
<label class="col-lg-3 col-form-label text-right">Preis : </label>
<div class="col-lg-4">
<input type="text" class="form-control" name="price" value="<?= $product['price'];?>">
</div>
<div class="col-lg-1">
<input type="text" class="form-control" name="currency" value="<?= $product['currency'];?>">
</div>
</div>
<div class="mb-3 row">
<label class="col-lg-3 col-form-label text-right">Aktivieren/Deaktivieren : </label>
<div class="col-lg-4">
<select class="form-select" name="is_act">
<option value="0" <?= $product['is_act']!='1' ? 'selected' : '';?>>Nein</option>
<option value="1" <?= $product['is_act']=='1' ? 'selected' : '';?>>Ja</option>
</select>
</div>
</div>
<div class="mb-3 row">
<label class="col-lg-3 col-form-label text-right">Hervorgehoben : </label>
<div class="col-lg-4">
<select class="form-select" name="is_feature">
<option value="0" <?= $product['is_feature']!='1' ? 'selected' : '';?>>Nein</option>
<option value="1" <?= $product['is_feature']=='1' ? 'selected' : '';?>>Ja</option>
</select>
</div>
</div>
<div class="mb-3 row">
<label class="col-lg-3 col-form-label text-right">TOP Produkt : </label>
<div class="col-lg-4">
<select class="form-select" name="is_top">
<option value="0" <?= $product['is_top']!='1' ? 'selected' : '';?>>Nein</option>
<option value="1" <?= $product['is_top']=='1' ? 'selected' : '';?>>Ja</option>
</select>
</div>
</div>
<div class="mb-3 row">
<label class="col-lg-3 col-form-label text-right">Button Link : </label>
<div class="col-lg-6">
<input type="text" class="form-control" name="link" value="<?= $product['link'];?>" placeholder="https://example.com">
</div>
</div>
<div class="mb-3 row">
<label class="col-lg-3 col-form-label text-right">Bullet Points : </label>
<div class="col-lg-6">
<?php
$sql=mysqli_query($conn, "SELECT * FROM ".$dbtable11);
while($point=mysqli_fetch_assoc($sql)){ ?>
<div class="mt-1 form-check form-switch">
<input class="form-check-input" type="checkbox" id="point<?= $point['id'];?>" name="point<?= $point['id'];?>" <?php if($point['card'.$id]=='1') echo 'checked';?>>
<label class="form-check-label" for="point<?= $point['id'];?>"><?= $point['title']; ?></label>
</div>
<?php
} ?>
</div>
</div>
<div class="row">
<div class="offset-lg-3 col-lg-9">
<?php $rand=rand(); $_SESSION['rand']=$rand; ?>
<input type="hidden" value="<?= $rand;?>" name="rand">
<a href="./products.php" class="btn btn-warning">Zurück</a>
<button type="submit" class="btn btn-primary">Speichern</button>
</div>
</div>
</form>
<br><br>
</div>
</div>
</div>
</div>
</section>
</main><!-- End #main -->
<?php
include_once './inc/footer.php';
?>
<script>
$('.sub11 ul').addClass('show');
$('.sub11 .nav-link').removeClass('collapsed');
</script>