Размер файла: 1.63Kb
<?php
require '../inc/func.php';
bk_head('Sửa Album');
require '../inc/head.php';
if(!$user) {
header('Location: /index.php');
}
echo '<div class="list1"><div class="tt"> Sửa tên album</div>';
if(isset($_GET['dell'])) {
echo '<div class="shadow">';
$num = num($_GET['num']);
$qq = mysql_fetch_assoc(mysql_query("SELECT * FROM `album` WHERE `id` = '$num'"));
if ($qq['user'] != $userid) {
header('location: index.php');
}
$w = mysql_query("SELECT * FROM `album_photo` WHERE `album` = '$qq[id]'");
if(mysql_num_rows($w)) {
err('Lỗi! Trong album còn ảnh!');
} else {
mysql_query("DELETE FROM `album` WHERE `id` = '$num'");
mysql_query("OPTIMIZE TABLE `album`");
header('location: index.php');
}
echo '/<div>';
}
if(isset($_GET['edit_album']) && !empty($_POST['name'])) {
$name = bk_check($_POST['name']);
$id = num($_GET['num']);
if(strlen($name) > 3 && strlen($name) < 20){
mysql_query("UPDATE `album` SET `name` = '$name', `time` = '" .time(). "', `user` = '$userid' WHERE `id` = '$id'");
err('Đổi tên album <b>' . $name . '</b> thành công.');
}else{
err('Name quá ngắn!');
}
}
$id = num($_GET['num']);
$album = mysql_fetch_assoc(mysql_query("SELECT * FROM `album` WHERE `id` = '$id'"));
if($album['user'] != $userid) {
err ('Lỗi!');
}
echo '<div class="shadow">';
echo '<form method="post" action="?num=' . $id . '&edit_album">
Tên album: <br />
<input type="text" name="name" value="' . $album['name'] . '" /> <br />';
echo '
<input type="submit" value="Save" /></form>
<a class="tch" href="index.php">← Back</a>';
echo '</div></div>';
bk_foot();