Файл: Source/admin/edit_prize.php
Строк: 77
<?php
/*
* Script name: Points4Prize
* Author: Soft Projects
* Date created: 15/07/2015
*/
$ID = (int) htmlspecialchars($_GET['id']);
include "common.php";
head();
?>
<script src="//cdn.ckeditor.com/4.4.7/basic/ckeditor.js"></script>
<div class="body content rows scroll-y">
<!-- Page header -->
<div class="page-heading">
<h1><b>Edit prize</b> </h1>
</div>
<!-- End page header -->
<!-- Begin info box -->
<div class="row">
<div class="col-md-12">
<div class="box-info">
<h2>Edit prize</h2>
<?php
if (isset($_POST['edit'])) {
$ime = htmlspecialchars($_POST['ime']);
$opisanie = htmlspecialchars($_POST['opisanie']);
$snimka = htmlspecialchars($_POST['snimka']);
$snimka2 = htmlspecialchars($_POST['snimka2']);
$snimka3 = htmlspecialchars($_POST['snimka3']);
$tochki = (int) htmlspecialchars($_POST['tochki']);
$kolichestwo = (int) htmlspecialchars($_POST['kolichestwo']);
if ($ime == NULL) {
echo "<div class='alert alert-danger' role='alert'>Please add name.</div>";
} elseif ($opisanie == NULL) {
echo "<div class='alert alert-danger' role='alert'>Please add description.</div>";
} elseif ($snimka == NULL) {
echo "<div class='alert alert-danger' role='alert'>Please add images.</div>";
}else {
mysql_query("UPDATE `vn_prizes` SET "
. "`title` = '$ime', "
. "`description`='$opisanie',"
. "`image`='$snimka',"
. "`image2`='$snimka2',"
. "`image3`='$snimka3',"
. "`points`='$tochki',"
. "`quantity`='$kolichestwo'"
. " WHERE `id` =$ID");
echo '<div class="alert alert-success" role="alert">The prize was successfully edited.</div>';
}
}
$result = mysql_query("SELECT * FROM `vn_prizes` WHERE `id`= $ID");
$row = mysql_fetch_array($result);
?>
<form action="" method="post">
<p>
<label>
Prize name
</label>
<input name="ime" value="<?php echo $row['title']; ?>" class="form-control" type="text">
</p>
<p>
<label>
Description
</label>
<textarea name="opisanie" class="form-control" rows="3"><?php echo $row['description']; ?></textarea>
<script>
CKEDITOR.replace('opisanie');
</script>
</p>
<p>
<label>
Image
</label>
<input name="snimka" value="<?php echo $row['image']; ?>" class="form-control" type="text">
</p>
<p>
<label>
Image 2
</label>
<input name="snimka2" value="<?php echo $row['image2']; ?>" class="form-control" type="text">
</p>
<p>
<label>
Image 3
</label>
<input name="snimka3" value="<?php echo $row['image3']; ?>" class="form-control" type="text">
</p>
<p>
<label>
Points
</label>
<input name="tochki" value="<?php echo $row['points']; ?>" class="form-control" type="text">
</p>
<p>
<label>
Quantity
</label>
<input name="kolichestwo" value="<?php echo $row['quantity']; ?>" class="form-control" type="text">
</p>
<input type="submit" class="btn btn-success" name="edit" value="Edit Prize" />
</form>
</div>
<?php
footer();
?>
</div>
</div>