Przedszkolak
Postów: 15 Ostrzeżeń: 1
Data rejestracji: 03.02.2008 19:07
|
Witam!
Jako, że dopiero co zaczynam swoją przygodę z PHP bardzo proszę o pomoc w skończeniu pliku.
Mam problem z zapisem i edycją artykułów/informacji ponieważ dodałem nowe pola do pliku article.php ale przy próbie zapisania/dodania informacji niestety nic w bazie się nie zapisuje. Oczywiście pola w bazie zostały utworzone.
Jeżeli mógłby mi ktoś pomóc w rozwiązaniu problemu było by super.
Poniżej przedstawiam przerobiony kod:
<?php
/*-------------------------------------------------------+
| PHP-Fusion Content Management System
| Copyright (C) 2002 - 2008 Nick Jones
| http://www.php-fusion.co.uk/
+--------------------------------------------------------+
| Filename: articles.php
| Author: Nick Jones (Digitanium)
+--------------------------------------------------------+
| This program is released as free software under the
| Affero GPL license. You can redistribute it and/or
| modify it under the terms of this license which you
| can read by viewing the included agpl.txt or online
| at http://www.gnu.org/licenses/agpl.html. Removal of this
| copyright header is strictly prohibited without
| written permission from the original author(s).
+--------------------------------------------------------*/
require_once "../maincore.php";
require_once THEMES."templates/admin_header_mce.php";
include LOCALE.LOCALESET."admin/articles.php";
if (!checkrights("A") || !defined("iAUTH") || $_GET['aid'] != iAUTH) { redirect("../index.php"); }
if ($settings['tinymce_enabled'] == 1) {
echo "<script language='javascript' type='text/javascript'>advanced();</script>\n";
} else {
require_once INCLUDES."html_buttons_include.php";
}
if (isset($_GET['status']) && !isset($message)) {
if ($_GET['status'] == "sn") {
$message = $locale['410'];
} elseif ($_GET['status'] == "su") {
$message = $locale['411'];
} elseif ($_GET['status'] == "del") {
$message = $locale['412'];
}
if ($message) { echo "<div class='admin-message'>".$message."</div>\n"; }
}
$result = dbquery("SELECT * FROM ".DB_ARTICLE_CATS);
if (dbrows($result)) {
if (isset($_POST['save'])) {
$subject = stripinput($_POST['subject']);
$czas_trwania = stripinput($_POST['czas_trwania']);
$data_projekcji = stripinput($_POST['data_projekcji']);
$godzina_projekcji = stripinput($_POST['godzina_projekcji']);
$ulgowy = stripinput($_POST['ulgowy']);
$normalny = stripinput($_POST['normalny']);
$produkcja = stripinput($_POST['produkcja']);
$gatunek = stripinput($_POST['gatunek']);
$zwiastun = stripinput($_POST['zwiastun']);
$plakat = stripinput($_POST['plakat']);
$nazwa_opisu = stripinput($_POST['nazwa_opisu']);
$link_opisu = stripinput($_POST['link_opisu']);
$body = addslash($_POST['body']);
$draft = isset($_POST['article_draft']) ? "1" : "0";
if ($settings['tinymce_enabled'] != 1) { $breaks = isset($_POST['line_breaks']) ? "y" : "n"; } else { $breaks = "n"; }
$comments = isset($_POST['article_comments']) ? "1" : "0";
$ratings = isset($_POST['article_ratings']) ? "1" : "0";
if (isset($_POST['article_id']) && isnum($_POST['article_id'])) {
$result = dbquery("UPDATE ".DB_ARTICLES." SET article_cat='".intval($_POST['article_cat'])."', article_subject='$subject', article_czas_trwania='$czas_trwania', article_produkcja='$produkcja', article_gatunek='$gatunek', article_plakat='$plakat', article_snippet='$body', article_article='$body2', article_draft='$draft', article_breaks='$breaks', article_allow_comments='$comments', article_allow_ratings='$ratings' WHERE article_id='".$_POST['article_id']."'");
redirect(FUSION_SELF.$aidlink."&status=su");
} else {
$result = dbquery("INSERT INTO ".DB_ARTICLES." (article_cat, article_subject, article_czas_trwania, article_produkcja, article_gatunek, article_plakat, article_snippet, article_article, article_draft, article_breaks, article_name, article_datestamp, article_reads, article_allow_comments, article_allow_ratings) VALUES ('".intval($_POST['article_cat'])."', '$subject', '$czas_trwania', '$produkcja', '$gatunek', '$plakat', '$body', '$body2', '$draft', '$breaks', '".$userdata['user_id']."', '".time()."', '0', '$comments', '$ratings')");
redirect(FUSION_SELF.$aidlink."&status=sn");
}
} else if (isset($_POST['delete']) && (isset($_POST['article_id']) && isnum($_POST['article_id']))) {
$result = dbquery("DELETE FROM ".DB_ARTICLES." WHERE article_id='".$_POST['article_id']."'");
$result = dbquery("DELETE FROM ".DB_COMMENTS." WHERE comment_item_id='".$_POST['article_id']."' and comment_type='A'");
$result = dbquery("DELETE FROM ".DB_RATINGS." WHERE rating_item_id='".$_POST['article_id']."' and rating_type='A'");
redirect(FUSION_SELF.$aidlink."&status=del");
} else {
if (isset($_POST['preview'])) {
$article_cat = $_POST['article_cat'];
$subject = stripinput($_POST['subject']);
$czas_trwania = stripinput($_POST['czas_trwania']);
$data_projekcji = stripinput($_POST['data_projekcji']);
$godzina_projekcji = stripinput($_POST['godzina_projekcji']);
$ulgowy = stripinput($_POST['ulgowy']);
$normalny = stripinput($_POST['normalny']);
$produkcja = stripinput($_POST['produkcja']);
$gatunek = stripinput($_POST['gatunek']);
$zwiastun = stripinput($_POST['zwiastun']);
$plakat = stripinput($_POST['plakat']);
$nazwa_opisu = stripinput($_POST['nazwa_opisu']);
$link_opisu = stripinput($_POST['link_opisu']);
$body = phpentities(stripslash($_POST['body']));
$bodypreview = str_replace("src='".str_replace("../", "", IMAGES_A), "src='".IMAGES_A, stripslash($_POST['body']));
$draft = isset($_POST['article_draft']) ? " checked='checked'" : "";
if (isset($_POST['line_breaks'])) {
$breaks = " checked='checked'";
$bodypreview = nl2br($bodypreview);
} else {
$breaks = "";
}
$comments = isset($_POST['article_comments']) ? " checked='checked'" : "";
$ratings = isset($_POST['article_ratings']) ? " checked='checked'" : "";
opentable($subject);
echo $bodypreview."\n";
closetable();
}
$result = dbquery("SELECT * FROM ".DB_ARTICLES." ORDER BY article_draft DESC, article_datestamp DESC");
if (dbrows($result)) {
$editlist = ""; $sel = "";
while ($data = dbarray($result)) {
if ((isset($_POST['article_id']) && isnum($_POST['article_id'])) || (isset($_GET['article_id']) && isnum($_GET['article_id']))) {
$article_id = isset($_POST['article_id']) ? $_POST['article_id'] : $_GET['article_id'];
$sel = ($article_id == $data['article_id'] ? " selected='selected'" : "");
} else {
$sel = "";
}
$editlist .= "<option value='".$data['article_id']."'".$sel.">".($data['article_draft'] ? $locale['433']." " : "").$data['article_subject']."</option>\n";
}
opentable($locale['402']);
echo "<div style='text-align:center'>\n<form name='selectform' method='post' action='".FUSION_SELF.$aidlink."&action=edit'>\n";
echo "<select name='article_id' class='textbox' style='width:250px;'>\n".$editlist."</select>\n";
echo "<input type='submit' name='edit' value='".$locale['420']."' class='button' />\n";
echo "<input type='submit' name='delete' value='".$locale['421']."' onclick='return DeleteArticle();' class='button' />\n";
echo "</form>\n</div>\n";
closetable();
}
if ((isset($_GET['action']) && $_GET['action'] == "edit") && (isset($_POST['article_id']) && isnum($_POST['article_id'])) || (isset($_GET['article_id']) && isnum($_GET['article_id']))) {
$result = dbquery("SELECT * FROM ".DB_ARTICLES." WHERE article_id='".(isset($_POST['article_id']) ? $_POST['article_id'] : $_GET['article_id'])."'");
if (dbrows($result)) {
$data = dbarray($result);
$article_cat = $data['article_cat'];
$subject = $data['article_subject'];
$czas_trwania = $data['article_czas_trwania'];
$data_projekcji = $data['article_data_projekcji'];
$godzina_projekcji = $data['article_godzina_projekcji'];
$ulgowy = $data['article_ulgowy'];
$normalny = $data['article_normalny'];
$produkcja = $data['article_produkcja'];
$gatunek = $data['article_gatunek'];
$zwiastun = $data['article_zwiastun'];
$plakat = $data['article_plakat'];
$nazwa_opisu = $data['article_nazwa_opisu'];
$link_opisu = $data['article_link_opisu'];
$body = phpentities(stripslashes($data['article_snippet']));
$draft = $data['article_draft'] ? " unlock='unlock'" : "";
$breaks = $data['article_breaks'] == "y" ? " checked='checked'" : "";
$comments = $data['article_allow_comments'] ? " unlock='unlock'" : "";
$ratings = $data['article_allow_ratings'] ? " unlock='unlock'" : "";
} else {
redirect(FUSION_SELF.$aidlink);
}
}
if ((isset($_POST['article_id']) && isnum($_POST['article_id'])) || (isset($_GET['article_id']) && isnum($_GET['article_id']))) {
opentable($locale['401']);
} else {
if (!isset($_POST['preview'])) {
$subject = "";
$czas_trwania = "";
$data_projekcji = "";
$godzina_projekcji = "";
$ulgowy = "";
$normalny = "";
$produkcja = "";
$gatunek = "";
$zwiastun = "";
$plakat = "";
$nazwa_opisu = "";
$link_opisu = "";
$body = "";
$draft = "";
$breaks = " checked='checked'";
$comments = " unlock='unlock'";
$ratings = " unlock='unlock'";
}
opentable($locale['400']);
}
$result = dbquery("SELECT * FROM ".DB_ARTICLE_CATS." ORDER BY article_cat_name DESC");
$catlist = ""; $sel = "";
while ($data = dbarray($result)) {
if (isset($article_cat)) $sel = ($article_cat == $data['article_cat_id'] ? " selected='selected'" : "");
$catlist .= "<option value='".$data['article_cat_id']."'$sel>".$data['article_cat_name']."</option>\n";
}
echo "<form name='inputform' method='post' action='".FUSION_SELF.$aidlink."' onsubmit='return ValidateForm(this)'>\n";
echo "<table cellpadding='0' cellspacing='0' class='center'>\n<tr>\n";
echo "<td width='100' class='tbl'>".$locale['422']."</td>\n";
echo "<td class='tbl'><select name='article_cat' class='repertuar' style='width:250px;'>".$catlist."</select></td>\n";
echo "</tr>\n<tr>\n";
echo "<td width='100' class='tbl'>".$locale['423']."</td>\n";
echo "<td class='tbl'><input type='text' name='subject' value='$subject' class='repertuar' style='width:250px;' /></td>\n";
echo "</tr>\n<tr>\n";
/* DODATKOWE POLA */
echo "<td width='100' class='tbl'>Data projekcji: </td>\n";
echo "<td class='tbl'><input type='text' name='data_projekcji' value='$data_projekcji' class='repertuar' style='width:150px;' />
godzina <input type='text' name='godzina_projekcji' value='$godzina_projekcji' class='repertuar' style='width:42px;' />
</td>\n";
echo "</tr>\n<tr>\n";
echo "<td width='100' class='tbl'>Ceny biletów: </td>\n";
echo "<td class='tbl'><input type='text' name='ulgowy' value='$ulgowy' class='repertuar' style='width:20px;' /> zł ulgowy
<input type='text' name='normalny' value='$normalny' class='repertuar' style='width:20px;' /> zł normalny
</td>\n";
echo "</tr>\n<tr>\n";
echo "<td width='100' class='tbl'>Czas trwania: </td>\n";
echo "<td class='tbl'><input type='text' name='czas_trwania' value='$czas_trwania' class='repertuar' style='width:250px;' /></td>\n";
echo "</tr>\n<tr>\n";
echo "<td width='100' class='tbl'>Produkcja: </td>\n";
echo "<td class='tbl'><input type='text' name='produkcja' value='$produkcja' class='repertuar' style='width:250px;' /></td>\n";
echo "</tr>\n<tr>\n";
echo "<td width='100' class='tbl'>Gatunek: </td>\n";
echo "<td class='tbl'><input type='text' name='gatunek' value='$gatunek' class='repertuar' style='width:250px;' /></td>\n";
echo "</tr>\n<tr>\n";
echo "<td width='100' class='tbl'>Zwiastun (link): </td>\n <td class='tbl'>";
?><input type="checkbox" name="nazwa" value="wartość" onclick="document.getElementById('identyfikator').style.display = this.checked ? 'block' : 'none'; this.form.elements['zwiastun'].disabled = this.form.elements['nazwa3'].disabled = !this.checked" />
<div id="identyfikator" style="display: none" >
<? echo "<input type='text' name='zwiastun' value='$zwiastun' class='repertuar' style='width:250px;' />"; ?>
</div>
<?
echo "</td>\n</tr>\n<tr>\n";
echo "<td width='100' class='tbl'>Plakat (link): </td>\n";
echo "<td class='tbl'><input type='text' name='plakat' value='$plakat' class='repertuar' style='width:450px;' /></td>\n";
echo "</tr>\n<tr>\n";
echo "<td width='100' class='tbl'>Nazwa opisu oryginalnego: </td>\n";
echo "<td class='tbl'><input type='text' name='nazwa_opisu' value='$nazwa_opisu' class='repertuar' style='width:250px;' /></td>\n";
echo "</tr>\n<tr>\n";
echo "<td width='100' class='tbl'>Link do opisu oryginalnego: </td>\n";
echo "<td class='tbl'><input type='text' name='link_opisu' value='$link_opisu' class='repertuar' style='width:250px;' /></td>\n";
echo "</tr>\n<tr>\n";
/*KONIEC DODATKOWYCH POL*/
echo "<td valign='top' width='100' class='tbl'>".$locale['424']."</td>\n";
echo "<td class='tbl'><textarea name='body' cols='95' rows='20' class='repertuar' style='width:98%'>".$body."</textarea></td>\n";
echo "</tr>\n";
if ($settings['tinymce_enabled'] != 1) {
echo "<tr>\n<td class='tbl'></td>\n<td class='tbl'>\n";
echo display_html("inputform", "plakat", true, true, true, IMAGES_A);
echo "</td>\n</tr>\n";
}
echo "<tr>\n";
echo "<td class='tbl'></td><td class='tbl'>\n";
if ($settings['tinymce_enabled'] != 1) { echo "<label><input type='checkbox' name='line_breaks' value='yes'".$breaks." /> ".$locale['427']."</label><br />\n"; }
echo "</tr>\n<tr>\n";
echo "<td align='center' colspan='2' class='tbl'><br />\n";
if ((isset($_POST['article_id']) && isnum($_POST['article_id'])) || (isset($_GET['article_id']) && isnum($_GET['article_id']))) {
echo "<input type='hidden' name='article_id' value='".(isset($_POST['article_id']) ? $_POST['article_id'] : $_GET['article_id'])."' />\n";
}
echo "<input type='submit' name='preview' value='".$locale['430']."' class='button' />\n";
echo "<input type='submit' name='save' value='".$locale['431']."' class='button' /></td>\n";
echo "</tr>\n</table>\n</form>\n";
closetable();
echo "<script type='text/javascript'>"."\n"."function DeleteArticle() {\n";
echo "return confirm('".$locale['451']."');\n}\n";
echo "function ValidateForm(frm) {"."\n"."if(frm.subject.value=='') {\n";
echo "alert('".$locale['450']."');"."\n"."return false;\n}\n}\n</script>\n";
}
} else {
opentable($locale['403']);
echo "<div style='text-align:center'>".$locale['452']."<br />\n".$locale['453']."<br />\n";
echo "<a href='article_cats.php".$aidlink."'>".$locale['454']."</a>".$locale['455']."</div>\n";
closetable();
}
require_once THEMES."templates/footer.php";
?>
Edytowane przez Pieka dnia 07.05.2011 11:51:06
|