Forum

Php checkbox icin y...
 
Bildirimler
Hepsini Temizle

Php checkbox icin yardiminiza ihtiyacim var

3 Yazılar
2 Üyeler
0 Reactions
1,286 Görüntüleme
(@MesutOZCAN55)
Gönderiler: 5
Active Member
Konu başlatıcı
 

üstadlarim öncelikle günaydın. Kullandigim hazir cms scriptinde bildirimlerim acip kapatilabilecek bir checkbox ayar bölümü yapmaya calisiyorum fakat tikandim kaldim. İsin asli php dilini sıfırdan yazamiyorum fakat orta duzeyde editleyip duzenleyebiliyorum. Scriptimde hazir ayarlar bolumune mysqlden users tablosunun notif_mail ve notif_sys_mail column larindaki verileri 0 ise kapali 1 ise açık verisini cekip kullanıcının istedigi bildirimi 0 veya 1 postunu gondererek acip kapatabilmesini saglamayi calisiyorum. Daha once checkbox çalışmam hiç olmamıştı ve denedim beceremedim konu hakkinda yardimci olabilirseniz sevinirim.

settings.php dosyam

$lng_set = core::load_lng('settings');
$textl = $lng['settings'];
require('../incfiles/head.php');

/*
-----------------------------------------------------------------
Проверяем права доступа
-----------------------------------------------------------------
*/
if ($user['id'] != $user_id) {
echo functions::display_error($lng['access_forbidden']);
require('../incfiles/end.php');
exit;
}

$menu = array(
(!$mod ? '<b>' . $lng['common_settings'] . '</b>' : '<a href="profile.php?act=settings">' . $lng['common_settings'] . '</a>'),
($mod == 'forum' ? '<b>' . $lng['forum'] . '</b>' : '<a href="profile.php?act=settings&amp;mod=forum">' . $lng['forum'] . '</a>'),
($mod == 'mail' ? '<b>' . $lng['mail'] . '</b>' : '<a href="profile.php?act=settings&amp;mod=mail">' . $lng['mail'] . '</a>'),
($mod == 'bildirim' ? '<b>' . $lng['bildirim'] . '</b>' : '<a href="profile.php?act=settings&amp;mod=bildirim">' . $lng['bildirim'] . '</a>'),
);

/*
-----------------------------------------------------------------
Пользовательские настройки
-----------------------------------------------------------------
*/
switch ($mod) {
case 'bildirim':

Buraya ne yazacağımı bilmiyorum. mysql den notif_mail değeri 0 ise kapalı 1 ise açık yazacak hemen altındada notif_sys_mail değeri 0 ise kapalı 1 açık yazacak. kullanıcı istediği zaman açıp kapatabilecek.

break;

case 'mail':
echo '<div class="phdr"><b>' . $lng['settings'] . '</b> | ' . $lng['mail'] . '</div>' .
'<div class="topmenu">' . functions::display_menu($menu) . '</div>';

$set_mail_user = unserialize($datauser['set_mail']);
if (isset($_POST['submit'])) {
$set_mail_user['access'] = isset($_POST['access']) && $_POST['access'] >= 0 && $_POST['access'] <= 2 ? abs(intval($_POST['access'])) : 0;
mysql_query("UPDATE `users` SET `set_mail` = '" . mysql_real_escape_string(serialize($set_mail_user) ) . "' WHERE `id` = '$user_id'");
}

echo '<form method="post" action="profile.php?act=settings&amp;mod=mail">' .
'<div class="menu">' .
'<strong>' . $lng_profile['write_messages'] . '</strong><br />' .
'<input type="radio" value="0" name="access" ' . (!$set_mail_user['access'] ? 'checked="checked"' : '') . '/> ' . $lng_profile['write_all'] . '<br />' .
'<input type="radio" value="1" name="access" ' . ($set_mail_user['access'] == 1 ? 'checked="checked"' : '') . '/> ' . $lng_profile['write_contacts'] . '<br />' .
'<input type="radio" value="2" name="access" ' . ($set_mail_user['access'] == 2 ? 'checked="checked"' : '') . '/> ' . $lng_profile['write_friends'] .
'<br/><p><input type="submit" name="submit" value="' . $lng['save'] . '"/></p></div></form>' .
'<div class="phdr"> </div>';
break;

case 'forum':
/*
-----------------------------------------------------------------
Настройки Форума
-----------------------------------------------------------------
*/
echo '<div class="phdr"><b>' . $lng['settings'] . '</b> | ' . $lng['forum'] . '</div>' .
'<div class="topmenu">' . functions::display_menu($menu) . '</div>';
$set_forum = array();
$set_forum = unserialize($datauser['set_forum']);
if (isset($_POST['submit'])) {
$set_forum['farea'] = isset($_POST['farea']);
$set_forum['upfp'] = isset($_POST['upfp']);
$set_forum['preview'] = isset($_POST['preview']);
$set_forum['postclip'] = isset($_POST['postclip']) ? intval($_POST['postclip']) : 1;
if ($set_forum['postclip'] < 0 || $set_forum['postclip'] > 2) {
$set_forum['postclip'] = 1;
}
mysql_query("UPDATE `users` SET `set_forum` = '" . mysql_real_escape_string(serialize($set_forum)) . "' WHERE `id` = '$user_id'");
echo '<div class="gmenu">' . $lng['settings_saved'] . '</div>';
}
if (isset($_GET['reset']) || empty($set_forum)) {
$set_forum = array();
$set_forum['farea'] = 0;
$set_forum['upfp'] = 0;
$set_forum['preview'] = 1;
$set_forum['postclip'] = 1;
mysql_query("UPDATE `users` SET `set_forum` = '" . mysql_real_escape_string(serialize($set_forum)) . "' WHERE `id` = '$user_id'");
echo '<div class="rmenu">' . $lng['settings_default'] . '</div>';
}
echo '<form action="profile.php?act=settings&amp;mod=forum" method="post">' .
'<div class="menu"><p><h3>' . $lng_set['main_settings'] . '</h3>' .
'<input name="upfp" type="checkbox" value="1" ' . ($set_forum['upfp'] ? 'checked="checked"' : '') . ' /> ' . $lng_set['sorting_return'] . '<br/>' .
'<input name="farea" type="checkbox" value="1" ' . ($set_forum['farea'] ? 'checked="checked"' : '') . ' /> ' . $lng_set['field_on'] . '<br/>' .
'<input name="preview" type="checkbox" value="1" ' . ($set_forum['preview'] ? 'checked="checked"' : '') . ' /> ' . $lng['preview'] . '<br/>' .
'</p><p><h3>' . $lng_set['clip_first_post'] . '</h3>' .
'<input type="radio" value="2" name="postclip" ' . ($set_forum['postclip'] == 2 ? 'checked="checked"' : '') . '/> ' . $lng_set['always'] . '<br />' .
'<input type="radio" value="1" name="postclip" ' . ($set_forum['postclip'] == 1 ? 'checked="checked"' : '') . '/> ' . $lng_set['in_not_read'] . '<br />' .
'<input type="radio" value="0" name="postclip" ' . (!$set_forum['postclip'] ? 'checked="checked"' : '') . '/> ' . $lng_set['never'] .
'</p><p><input type="submit" name="submit" value="' . $lng['save'] . '"/></p></div></form>' .
'<div class="phdr"><a href="profile.php?act=settings&amp;mod=forum&amp;r eset">' . $lng['reset_settings'] . '</a></div>';
break;

default:
echo '<div class="phdr"><b>' . $lng['settings'] . '</b> | ' . $lng['common_settings'] . '</div>' .
'<div class="topmenu">' . functions::display_menu($menu) . '</div>';
if (isset($_POST['submit'])) {
/*
-----------------------------------------------------------------
Записываем новые настройки, заданные пользователем
-----------------------------------------------------------------
*/
$set_user['timeshift'] = isset($_POST['timeshift']) ? intval($_POST['timeshift']) : 0;
$set_user['avatar'] = isset($_POST['avatar']);
$set_user['smileys'] = isset($_POST['smileys']);
$set_user['translit'] = isset($_POST['translit']);
$set_user['digest'] = isset($_POST['digest']);
$set_user['direct_url'] = isset($_POST['direct_url']);
$set_user['field_h'] = isset($_POST['field_h']) ? abs(intval($_POST['field_h'])) : 3;
$set_user['kmess'] = isset($_POST['kmess']) ? abs(intval($_POST['kmess'])) : 10;
$set_user['quick_go'] = isset($_POST['quick_go']);
if ($set_user['timeshift'] < -12)
$set_user['timeshift'] = -12;
elseif ($set_user['timeshift'] > 12)
$set_user['timeshift'] = 12;
if ($set_user['kmess'] < 5)
$set_user['kmess'] = 5;
elseif ($set_user['kmess'] > 99)
$set_user['kmess'] = 99;
if ($set_user['field_w'] < 10)
$set_user['field_w'] = 10;
elseif ($set_user['field_w'] > 80)
$set_user['field_w'] = 80;
if ($set_user['field_h'] < 1)
$set_user['field_h'] = 1;
elseif ($set_user['field_h'] > 9)
$set_user['field_h'] = 9;

// Устанавливаем скин
foreach (glob('../theme/*/*.css') as $val)
$theme_list[] = array_pop(explode('/', dirname($val)));
$set_user['skin'] = isset($_POST['skin']) && in_array($_POST['skin'], $theme_list) ? functions::check($_POST['skin']) : $set['skindef'];

// Устанавливаем язык
$lng_select = isset($_POST['iso']) ? trim($_POST['iso']) : false;
if ($lng_select && array_key_exists($lng_select, core::$lng_list)) {
$set_user['lng'] = $lng_select;
unset($_SESSION['lng']);
}

// Записываем настройки
mysql_query("UPDATE `users` SET `set_user` = '" . mysql_real_escape_string(serialize($set_user)) . "' WHERE `id` = '$user_id'");
$_SESSION['set_ok'] = 1;
header('Location: profile.php?act=settings');
exit;
} elseif (isset($_GET['reset']) || empty($set_user)) {
/*
-----------------------------------------------------------------
Задаем настройки по-умолчанию
-----------------------------------------------------------------
*/
mysql_query("UPDATE `users` SET `set_user` = '' WHERE `id` = '$user_id'");
$_SESSION['reset_ok'] = 1;
header('Location: profile.php?act=settings');
exit;
}

/*
-----------------------------------------------------------------
Форма ввода пользовательских настроек
-----------------------------------------------------------------
*/
if (isset($_SESSION['set_ok'])) {
echo '<div class="rmenu">' . $lng['settings_saved'] . '</div>';
unset($_SESSION['set_ok']);
}
if (isset($_SESSION['reset_ok'])) {
echo '<div class="rmenu">' . $lng['settings_default'] . '</div>';
unset($_SESSION['reset_ok']);
}
echo '<form action="profile.php?act=settings" method="post" >' .
'<div class="menu"><p><h3>' . $lng['settings_clock'] . '</h3>' .
'<input type="text" name="timeshift" size="2" maxlength="3" value="' . core::$user_set['timeshift'] . '"/> ' . $lng['settings_clock_shift'] . ' (+-12)<br />' .
'<span style="font-weight:bold; background-color:#CCC">' . date("H:i", time() + (core::$system_set['timeshift'] + core::$user_set['timeshift']) * 3600) . '</span> ' . $lng['system_time'] .
'</p><p><h3>' . $lng['system_functions'] . '</h3>' .
'<input name="direct_url" type="checkbox" value="1" ' . (core::$user_set['direct_url'] ? 'checked="checked"' : '') . ' /> ' . $lng['direct_url'] . '<br />' .
'<input name="avatar" type="checkbox" value="1" ' . (core::$user_set['avatar'] ? 'checked="checked"' : '') . ' /> ' . $lng['avatars'] . '<br/>' .
'<input name="smileys" type="checkbox" value="1" ' . (core::$user_set['smileys'] ? 'checked="checked"' : '') . ' /> ' . $lng['smileys'] . '<br/>' .
'</p><p><h3>' . $lng['text_input'] . '</h3>' .
'<input type="text" name="field_h" size="2" maxlength="1" value="' . core::$user_set['field_h'] . '"/> ' . $lng['field_height'] . ' (1-9)<br />';
if (core::$lng_iso == 'ru' || core::$lng_iso == 'uk') echo '<input name="translit" type="checkbox" value="1" ' . (core::$user_set['translit'] ? 'checked="checked"' : '') . ' /> ' . $lng['translit'];
echo '</p><p><h3>' . $lng['apperance'] . '</h3>' .
'<input type="text" name="kmess" size="2" maxlength="2" value="' . core::$user_set['kmess'] . '"/> ' . $lng['lines_on_page'] . ' (5-99)' .
'</p>';

// Выбор темы оформления
echo '<p><h3>' . $lng['design_template'] . '</h3><select name="skin">';
foreach (glob('../theme/*/*.css') as $val) {
$dir = explode('/', dirname($val));
$theme = array_pop($dir);
echo '<option' . (core::$user_set['skin'] == $theme ? ' selected="selected">' : '>') . $theme . '</option>';
}
echo '</select></p>';

// Выбор языка
if (count(core::$lng_list) > 1) {
echo '<p><h3>' . $lng['language_select'] . '</h3>';
$user_lng = isset(core::$user_set['lng']) ? core::$user_set['lng'] : core::$lng_iso;
foreach (core::$lng_list as $key => $val) {
echo '<div><input type="radio" value="' . $key . '" name="iso" ' . ($key == $user_lng ? 'checked="checked"' : '') . '/> ' .
(file_exists('../images/flags/' . $key . '.gif') ? '<img src="../images/flags/' . $key . '.gif" alt=""/> ' : '') .
$val .
($key == core::$system_set['lng'] ? ' <small class="red">[' . $lng['default'] . ']</small>' : '') .
'</div>';
}
echo '</p>';
}

echo '<p><input type="submit" name="submit" value="' . $lng['save'] . '"/></p></div></form>' .
'<div class="phdr"><a href="profile.php?act=settings&amp;reset">' . $lng['reset_settings'] . '</a></div>';
}

users tablom :
id name name_lat password rights failed_login imname sex komm postforum postguest postchat yearofbirth datereg lastdate mail icq skype jabber www about live mibile status ip ip_via_proxy browser preg regadm mailvis dayb monthb sestime total_on_site lastpost rest_code rest_time movings place set_user set_forum set_mail karma_plus karma_minus karma_time karma_off comm_count comm_old smileys balans balans_day balans_time balls prosm_ank bot notif_mail notif_sys_mail

 

Simdiden yardimci olan olamayan herkese teşekkür ederim.

 
Gönderildi : 26/04/2017 13:29

(@volkanalkilic)
Gönderiler: 137
Estimable Member
 

Kullandığınız CMS'in dokümantasyonunu incelemenizi tavsiye ederim. Ayrıca aşağıda faydalı olabilecek bir örnek bulabilirsiniz;

https://www.youtube.com/watch?v=s6_fVUMXrV0

http://form.guide/php-form/php-form-select.html

https://www.idtech.com/blog/populating-a-combo-box-in-php-dynamically-from-mysql/

 
Gönderildi : 27/04/2017 00:53

(@MesutOZCAN55)
Gönderiler: 5
Active Member
Konu başlatıcı
 

Hocam ilgi ve alakaniz icin teşekkür ederim en ustte verdiginiz youtube linki kırık üstadım.

Üstadim Youtube olsun bloglar olsun dokumanlara ve orneklere cok baktim ve cok denedim hic calistiramadim. Alanimda sadece notif_mail ile notif_sys_mail yok daha fazlasi var. Ben bilerek bu ikisi icin yardim istedimki geri kalanini bakarak ekleyebileyim.

Ayrica üstadım bunu tamamladiktan sonra sitemin forum bolumune abonelik, gazete bolumunede haber botu yazdirmak istiyorum. İlgilenirseniz gorusmek istedim.

 
Gönderildi : 27/04/2017 03:50

Paylaş: