Chủ đề: [Share] Mod shop bút bi cho JohnCMS
![]() | ![]() ![]() ![]() ![]() 16:57 / 05.08.2016 |
Code cùi cũng chả có gì đặc sắc lắm
Đầu tiên tạo màu của bút. Vào css add code:
''.highlight('.butxlc{color: green}
.butxnb{color: blue}
.butcam{color: orange}
.butdo{color: red}').''
Thích thêm màu khác thì làm tương tự. Tạo trang butbi.php :
''.highlight('define('_IN_JOHNCMS', 1);
$textl = 'Mua Bút';
$headmod = 'nick';
require_once ("../incfiles/core.php");
require_once ("../incfiles/head.php");
if ($id && $id != $user_id) {
$req = mysql_query("SELECT * FROM `users` WHERE `id` = '$id' LIMIT 1");
if (mysql_num_rows($req)) {
$user = mysql_fetch_assoc($req);
}
else {
}
}
else {
$id = false;
$user = $datauser;
}
if (!$user_id) {
require_once ('../incfiles/head.php');
echo functions::display_error($lng['access_guest_forbidden']);
require_once ('../incfiles/end.php');
exit;
}
switch($act){
case 'mua' :
if ($user['balans'] < 5000)
echo 'Bạn không đủ 5000 xu';
else {
$but = ($_POST['but']);
mysql_query("UPDATE `users` SET `but` = '$but' ,`balans`=`balans`-5000 WHERE `id` = '$user_id' LIMIT 1");
echo 'Mua thành công!';
}
break;
default:
echo 'Chọn bút bạn muốn mua (5000 xu/chiếc):<br />';
echo '<form action="butbi.php?act=mua" name="but" method="post">';
echo '<input type="radio" name="but" value="butxnb"/> <font color="blue">Bút xanh nước biển</font><br />
<input type="radio" name="but" value="butxlc"/> <font color="green">Bút xanh lá cây</font><br />
<input type="radio" name="but" value="butcam"/> <font color="orange">Bút cam</font><br />
<input type="radio" name="but" value="butdo"/> <font color="red">Bút đỏ</font><br />';
echo '<input type="submit" name="submit" value="Mua"/></form>';
break;
}
require_once ("../incfiles/end.php");').''
Vào mysql chạy code này:
''.highlight('ALTER TABLE `users` ADD `but` VARCHAR( 40 ) NOT NULL DEFAULT 'black'').''
Muốn màu hiện ở đâu dùng code
$but = mysql_query("SELECT `but` FROM `users` WHERE `id` = '$user_id'");
<span class="'.$but.'">nơi hiện</span>
Có thể áp dụng với khung bình luận Forum, Chat,....
Nguồn: Mrp-Vn
Share: Caube_2k2
Đầu tiên tạo màu của bút. Vào css add code:
''.highlight('.butxlc{color: green}
.butxnb{color: blue}
.butcam{color: orange}
.butdo{color: red}').''
Thích thêm màu khác thì làm tương tự. Tạo trang butbi.php :
''.highlight('define('_IN_JOHNCMS', 1);
$textl = 'Mua Bút';
$headmod = 'nick';
require_once ("../incfiles/core.php");
require_once ("../incfiles/head.php");
if ($id && $id != $user_id) {
$req = mysql_query("SELECT * FROM `users` WHERE `id` = '$id' LIMIT 1");
if (mysql_num_rows($req)) {
$user = mysql_fetch_assoc($req);
}
else {
}
}
else {
$id = false;
$user = $datauser;
}
if (!$user_id) {
require_once ('../incfiles/head.php');
echo functions::display_error($lng['access_guest_forbidden']);
require_once ('../incfiles/end.php');
exit;
}
switch($act){
case 'mua' :
if ($user['balans'] < 5000)
echo 'Bạn không đủ 5000 xu';
else {
$but = ($_POST['but']);
mysql_query("UPDATE `users` SET `but` = '$but' ,`balans`=`balans`-5000 WHERE `id` = '$user_id' LIMIT 1");
echo 'Mua thành công!';
}
break;
default:
echo 'Chọn bút bạn muốn mua (5000 xu/chiếc):<br />';
echo '<form action="butbi.php?act=mua" name="but" method="post">';
echo '<input type="radio" name="but" value="butxnb"/> <font color="blue">Bút xanh nước biển</font><br />
<input type="radio" name="but" value="butxlc"/> <font color="green">Bút xanh lá cây</font><br />
<input type="radio" name="but" value="butcam"/> <font color="orange">Bút cam</font><br />
<input type="radio" name="but" value="butdo"/> <font color="red">Bút đỏ</font><br />';
echo '<input type="submit" name="submit" value="Mua"/></form>';
break;
}
require_once ("../incfiles/end.php");').''
Vào mysql chạy code này:
''.highlight('ALTER TABLE `users` ADD `but` VARCHAR( 40 ) NOT NULL DEFAULT 'black'').''
Muốn màu hiện ở đâu dùng code
$but = mysql_query("SELECT `but` FROM `users` WHERE `id` = '$user_id'");
<span class="'.$but.'">nơi hiện</span>
Có thể áp dụng với khung bình luận Forum, Chat,....
Nguồn: Mrp-Vn
Share: Caube_2k2