Exemple #1
0
$smarty = new Smarty();
$smarty->compile_check = TRUE;
$smarty->debugging = FALSE;
$smarty->template_dir = $smarty_dir . 'templates/';
$smarty->compile_dir = $smarty_dir . 'templates_c/';
$smarty->cache_dir = $smarty_dir . 'cache/';
$smarty->config_dir = $smarty_dir . 'configs/';
//передаем 'имя переменной' и 'значение'
$smarty->assign('title', 'Наше объявление');
$smarty->assign('cities', get_cities($db));
$smarty->assign('category', get_category($db));
if (filter_input(INPUT_POST, 'confirm_add')) {
    // кнопка добавить
    if (is_numeric($_POST['id_r'])) {
        // если присутствует метка id_r то сохраняем редактируемое объявление
        edit_ads($db, $_POST);
    } else {
        ads_ad($db, $_POST);
        // иначе добавляем новое объявление
    }
    restart();
    // вызываем restart(); для очистки формы
} elseif (filter_input(INPUT_POST, 'clear_form') || filter_input(INPUT_POST, 'back')) {
    // кнопка очистить форму  вызывает restart();
    restart();
} elseif (filter_input(INPUT_POST, 'clear_base')) {
    // по кнопке очистить базу очищаем БД
    mysqli_query($db, "delete from `advertisement` where id>0");
    restart();
} elseif (filter_input(INPUT_GET, 'del_ad')) {
    // ловим ключ del_ad в массиве $_GET
Exemple #2
0
$smarty->compile_check = TRUE;
$smarty->debugging = FALSE;
$smarty->template_dir = $smarty_dir . 'templates/';
$smarty->compile_dir = $smarty_dir . 'templates_c/';
$smarty->cache_dir = $smarty_dir . 'cache/';
$smarty->config_dir = $smarty_dir . 'configs/';
//передаем 'имя переменной' и 'значение'
$smarty->assign('title', 'Наше объявление');
$smarty->assign('citys', $citys);
$smarty->assign('categorys', $categorys);
connect_bd('localhost', 'root', '', 'main_bd');
if (isset($_POST['confirm_add'])) {
    // кнопка добавить
    if (is_numeric($_POST['id_r'])) {
        // если присутствует метка id_r то сохраняем редактируемое объявление
        edit_ads($_POST);
    } else {
        ads_ad($_POST);
        // иначе добавляем новое объявление
    }
    restart();
    // вызываем restart(); для очистки формы
} elseif (isset($_POST['clear_form']) || isset($_POST['back'])) {
    // кнопка очистить форму  вызывает restart();
    restart();
} elseif (isset($_POST['clear_base'])) {
    // по кнопке очистить базу очищаем БД
    mysql_query("delete from `advertisement` where id>0");
    restart();
} elseif (isset($_GET['del_ad'])) {
    // ловим ключ del_ad в массиве $_GET