I need your help guys,
I want to create jobs via the admin page as I do with the news
this is my ShowNewsPage.php in /includes/pages/adm
Display All
and this is the NewsPage.tpl
Display All
the sql table jobs looks like this
thanks for help
I want to create jobs via the admin page as I do with the news
this is my ShowNewsPage.php in /includes/pages/adm
PHP Source Code
- if (!allowedTo(str_replace(array(dirname(__FILE__), '\\', '/', '.php'), '', __FILE__))) throw new Exception("Permission error!");
- function ShowNewsPage(){
- global $LNG, $USER;
- if($_GET['action'] == 'send') {
- $edit_id = HTTP::_GP('id', 0);
- $title = $GLOBALS['DATABASE']->sql_escape(HTTP::_GP('title', '', true));
- $text = $GLOBALS['DATABASE']->sql_escape(HTTP::_GP('text', '', true));
- $query = ($_GET['mode'] == 2) ? "INSERT INTO ".NEWS." (`id` ,`user` ,`date` ,`title` ,`text`) VALUES ( NULL , '".$USER['username']."', '".TIMESTAMP."', '".$title."', '".$text."');" : "UPDATE ".NEWS." SET `title` = '".$title."', `text` = '".$text."', `date` = '".TIMESTAMP."' WHERE `id` = '".$edit_id."' LIMIT 1;";
- $GLOBALS['DATABASE']->query($query);
- } elseif($_GET['action'] == 'delete' && isset($_GET['id'])) {
- $GLOBALS['DATABASE']->query("DELETE FROM ".NEWS." WHERE `id` = '".HTTP::_GP('id', 0)."';");
- }
- $query = $GLOBALS['DATABASE']->query("SELECT * FROM ".NEWS." ORDER BY id ASC");
- while ($u = $GLOBALS['DATABASE']->fetch_array($query)) {
- $NewsList[] = array(
- 'id' => $u['id'],
- 'title' => $u['title'],
- 'date' => _date($LNG['php_tdformat'], $u['date'], $USER['timezone']),
- 'user' => $u['user'],
- 'confirm' => sprintf($LNG['nws_confirm'], $u['title']),
- );
- }
- $template = new template();
- if($_GET['action'] == 'edit' && isset($_GET['id'])) {
- $News = $GLOBALS['DATABASE']->getFirstRow("SELECT id, title, text FROM ".NEWS." WHERE id = '".$GLOBALS['DATABASE']->sql_escape($_GET['id'])."';");
- $template->assign_vars(array(
- 'mode' => 1,
- 'nws_head' => sprintf($LNG['nws_head_edit'], $News['title']),
- 'news_id' => $News['id'],
- 'news_title' => $News['title'],
- 'news_text' => $News['text'],
- ));
- } elseif($_GET['action'] == 'create') {
- $template->assign_vars(array(
- 'mode' => 2,
- 'nws_head' => $LNG['nws_head_create'],
- ));
- }
- $template->assign_vars(array(
- 'NewsList' => $NewsList,
- 'button_submit' => $LNG['button_submit'],
- 'nws_total' => sprintf($LNG['nws_total'], count($NewsList)),
- 'nws_news' => $LNG['nws_news'],
- 'nws_id' => $LNG['nws_id'],
- 'nws_title' => $LNG['nws_title'],
- 'nws_date' => $LNG['nws_date'],
- 'nws_from' => $LNG['nws_from'],
- 'nws_del' => $LNG['nws_del'],
- 'nws_create' => $LNG['nws_create'],
- 'nws_content' => $LNG['nws_content'],
- ));
- $template->show('NewsPage.tpl');
- }
and this is the NewsPage.tpl
HTML Source Code
- {include file="overall_header.tpl"}
- {include file="head_nav.tpl"}
- {nocache}{if isset($mode)}
- <form method="POST" action="?page=news&action=send&mode={$mode}">
- {if $news_id}<input name="id" type="hidden" value="{$news_id}">{/if}
- <table>
- <tr>
- <th colspan="2">{$nws_head}</th>
- </tr>
- <tr>
- <tr>
- <td width="25%">{$nws_title}</td><td><input type="text" name="title" value="{$news_title}"></td>
- </tr>
- <tr>
- <td>{$nws_content}</td><td><textarea cols="70" rows="10" name="text">{$news_text}</textarea></td>
- </tr>
- <tr>
- <td colspan="2"><input type="submit" name="Submit" value="{$button_submit}"></td>
- </tr>
- </table>
- </form>
- {/if}{/nocache}
- <table width="450">
- <tr>
- <th colspan="5">{$nws_news}</thd>
- </tr>
- <tr>
- <td>{$nws_id}</td>
- <td>{$nws_title}</td>
- <td>{$nws_date}</td>
- <td>{$nws_from}</td>
- <td>{$nws_del}</td>
- </tr>
- {foreach name=NewsList item=NewsRow from=$NewsList}<tr>
- <td><a href="?page=news&action=edit&id={$NewsRow.id}">{$NewsRow.id}</a></td>
- <td><a href="?page=news&action=edit&id={$NewsRow.id}">{$NewsRow.title}</a></td>
- <td><a href="?page=news&action=edit&id={$NewsRow.id}">{$NewsRow.date}</a></td>
- <td><a href="?page=news&action=edit&id={$NewsRow.id}">{$NewsRow.user}</a></td>
- <td><a href="?page=news&action=delete&id={$NewsRow.id}" onclick="return confirm('{$NewsRow.confirm}');"><img border="0" src="./styles/resource/images/alliance/CLOSE.png" width="16" height="16"></a></td>
- </tr>
- {/foreach}
- <tr><td colspan="5"><a href="?page=news&action=create">{$nws_create}</a></td></tr>
- <tr><td colspan="5">{$nws_total}</td></tr>
- </table>
- {include file="overall_footer.tpl"}
the sql table jobs looks like this
SQL-Query
- CREATE TABLE IF NOT EXISTS `uni1_jobs` (
- `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
- `date` int(11) NOT NULL,
- `title` varchar(64) CHARACTER SET utf8 NOT NULL,
- `text` text CHARACTER SET utf8 NOT NULL,
- `catID` int(11) NOT NULL DEFAULT '1',
- `is_active` int(11) NOT NULL DEFAULT '1',
- PRIMARY KEY (`id`)
- ) ENGINE=MyISAM DEFAULT CHARSET=utf8;
thanks for help