Rodrigo152 4 Posted January 15, 2021 Share Posted January 15, 2021 good morning, someone can help me with my site, is not publishing the news, I created a table in the db account but it did not solve, someone can help me. <? PHP if (isset ($ _ POST ['submit']) && $ _POST ['submit'] == "Submit") { if (! empty ($ _ POST ['title']) &&! empty ($ _ POST ['content']) && checkInt ($ _ POST ['category']) && checkBetween ($ _ POST ['tag'], 0.31 ) && checkBetween ($ _ POST ['month'], 1.12) && checkBetween ($ _ POST [year '], 1900, date ("Y", time ()) + 10) && checkBetween ($ _ POST [' hour ' ], 0.24) && checkBetween ($ _ POST ['minute'], 0.59)) { $ zeitStempel = mktime ($ _ POST ['hour'], $ _ POST ['minute'], 0, $ _ POST ['month'], $ _ POST ['tag'], $ _ POST [year ']); $ anzeigen = (isset ($ _ POST ['anzeigen']) && $ _POST ['anzeigen'] == "true")? 1: 0; $ wichtig = (isset ($ _ POST ['wichtig']) && $ _POST ['wichtig'] == "true")? 1: 0; $ sqlNews = "INSERT INTO" .SQL_HP_DB. ". news VALUES (NULL, '". Mysql_real_escape_string ($ _ POST [' title '])."', '". Mysql_real_escape_string ($ _ POST [' content '])."', '". $ ZeitStempel."', '". $ wichtig. "','". $ _ POST ['category']. "','". $ _ SESSION ['user_id']. "','". $ anzeigen. "')"; if (mysql_query ($ sqlNews, $ sqlHp)) { echo '<p class = "meldung_sucesso"> New news added successfully. </p>'; } else { echo '<p class = "meldung_erro"> An error has occurred, please try again. </p>'; } } } ?> Link to comment Share on other sites More sharing options...
monsterd2w4 4 Posted January 15, 2021 Share Posted January 15, 2021 <?PHP if(isset($_GET['id']) && checkInt($_GET['id'])) { $sqlNews = "SELECT * FROM ".SQL_HP_DB.".news WHERE anzeigen>0 AND id='".mysql_real_escape_string($_GET['id'])."' LIMIT 1"; $qryNews = mysql_query($sqlNews,$sqlHp); if(mysql_num_rows($qryNews)>0) { while($getNews = mysql_fetch_object($qryNews)) { echo'<div class="newsblock">'; echo'<h3>['.$newsKategorien[$getNews->kategorie].'] <b>'.$getNews->titel.'</b></h3>'; echo'<p>'.x_nl2br($getNews->inhalt).'</p>'; if($newsKategorien[$getNews->kategorie]=='Event') { echo'<p class="footer">post την <b>'.getDatum($getNews->datum).'</b> post <b>'.getZeit($getNews->datum).' </b></p>'; } else { echo'<p class="footer">post <b>'.getDatum($getNews->datum).'</b> post <b>'.getZeit($getNews->datum).' </b></p>'; } echo'</div>'; } } else { echo'<p class="meldung">post.</p>'; } echo'<p><a href="index.php?s=news">post </a></p>'; } else { $sqlNews = "SELECT * FROM ".SQL_HP_DB.".news WHERE anzeigen>0 AND kategorie!=2 ORDER BY datum DESC LIMIT 10"; $qryNews = mysql_query($sqlNews,$sqlHp); while($getNews = mysql_fetch_object($qryNews)) { $newsText = (strlen($getNews->inhalt)>400) ? substr($getNews->inhalt,0,strpos($getNews->inhalt,' ',400)).'... <a href="index.php?s=news&id='.$getNews->id.'">post</a>' : $getNews->inhalt; echo'<div class="newsblock">'; echo'<h3>['.$newsKategorien[$getNews->kategorie].'] <b><a href="index.php?s=news&id='.$getNews->id.'">'.$getNews->titel.'</a></b></h3>'; echo'<p>'.x_nl2br($newsText).'</p>'; echo'<p class="footer">post <b>'.getDatum($getNews->datum).'</b> post <b>'.getZeit($getNews->datum).' </b></p>'; echo'</div>'; } } ?> Link to comment Share on other sites More sharing options...
Management AZICKO 7340 Posted January 15, 2021 Management Share Posted January 15, 2021 Please, use PDO or mysqli Scamming ? Reselling ? metin2.download | metin2.dev | fr.metin2.dev | metin2dev.org | metin2.top | top-metin2.org Link to comment Share on other sites More sharing options...
Rodrigo152 4 Posted January 17, 2021 Author Share Posted January 17, 2021 I forgot to put the whole source, I don't know much about php and I wanted some help to solve this problem, if there is an error in the code. <? PHP if ($ _ SESSION ['user_admin']> = $ adminRights ['web_news']) { ?> <h2> Add News </h2> <p> From here you can edit or insert or delete a news about your server. </p> <h3> Recent news </h3> <? PHP if (isset ($ _ POST ['submit']) && $ _POST ['submit'] == "Submit") { if (! empty ($ _ POST ['title']) &&! empty ($ _ POST ['content']) && checkInt ($ _ POST ['category']) && checkBetween ($ _ POST ['tag'], 0.31 ) && checkBetween ($ _ POST ['month'], 1.12) && checkBetween ($ _ POST ['year'], 1900, date ("Y", time ()) + 10) && checkBetween ($ _ POST ['hour'], 0.24) && checkBetween ($ _ POST ['minute'], 0.59)) { $ zeitStempel = mktime ($ _ POST ['hour'], $ _ POST ['minute'], 0, $ _ POST ['month'], $ _ POST ['tag'], $ _ POST ['year']); // id titel inhalt datum hot kategorie author anzeigen $ anzeigen = (isset ($ _ POST ['anzeigen']) && $ _POST ['anzeigen'] == "true")? 1: 0; $ wichtig = (isset ($ _ POST ['wichtig']) && $ _POST ['wichtig'] == "true")? 1: 0; $ sqlNews = "INSERT INTO" .SQL_HP_DB. "news VALUES (NULL, '". Mysql_real_escape_string ($ _ POST [' title '])."', '". Mysql_real_escape_string ($ _ POST [' content '])."', '". $ ZeitStempel."', '". $ wichtig. "','". $ _ POST ['category']. "','". $ _ SESSION ['user_id']. "','". $ anzeigen. "')"; if (mysql_query ($ sqlNews, $ sqlHp)) { echo '<p class = "meldung_sucesso"> New news added successfully. </p>'; } else { echo '<p class = "meldung_erro"> An error has occurred, please try again. </p>'; } } } ?> <form method = "POST" action = "index.php? s = admin & a = news"> <table> <tr> <th class = "topLine"> Title: </th> <td class = "thell"> <input type = "text" size = "40" maxlength = "200" name = "titel" /> </td> </tr> <tr> <th class = "topLine"> Text of News: </th> <td class = "tdunkel"> <textarea style = "resize: none;" rows = "5" cols = "40" name = "inhalt"> </textarea> </td> </tr> <tr> <th class = "topLine"> Date: </th> <td class = "tdunkel"> <input type = "text" size = "2" maxlength = "2" value = "<? PHP echo date (" d ", time ());?>" name = "tag "/>.<input type =" text "size =" 2 "value =" <? PHP echo date ("m", time ());?> "maxlength =" 2 "name =" month "/>. <input type = "text" size = "4" maxlength = "4" value = "<? PHP echo date (" Y ", time ());?>" name = "year" /> - <input type = "text" size = "2" maxlength = "2" value = "<? PHP echo date (" H ", time ());?>" name = "hour" />: <input type = "text" size = "2" maxlength = "2" value = "<? PHP echo date (" i ", time ());?>" Name = "minute" /> </td> </tr> <tr> <th class = "topLine"> Category: </th> <td class = "thell"> <? PHP listNewsKat (); ?> </td> </tr> <tr> <th class = "topLine"> Important News ?: </th> <td class = "tdunkel"> <input type = "checkbox" name = "wichtig" value = "true" /> </td> </tr> <tr> <th class = "topLine"> View News: </th> <td class = "thell"> <input type = "checkbox" name = "anzeigen" value = "true" /> </td> </tr> <tr> <th class = "topLine" colspan = "2"> <input type = "submit" name = "submit" value = "Submit" /> </th> </tr> </table> </form> <h3> News List </h3> <table class = "fullrank_guild" style = "border-radius: 10px"> <tr> <th class = "topLine"> News ID </th> <th class = "topLine"> Data </th> <th class = "topLine"> Title </th> <th class = "topLine"> Category </th> <th class = "topLine"> Content </th> <th class = "topLine"> Active </th> <th class = "topLine"> Delete </th> </tr> <? PHP $ sqlNews = "SELECT * FROM" .SQL_HP_DB. "news ORDER BY datum DESC"; $ qryNews = mysql_query ($ sqlNews, $ sqlHp); $ x = 0; while ($ getNews = mysql_fetch_object ($ qryNews)) { $ nWichtig = ($ getNews-> hot> 0)? "./img/success.gif": "./img/fail.gif"; $ nAnzeigen = ($ getNews-> anzeigen> 0)? "./img/success.gif": "./img/fail.gif"; $ nTitel = (strlen ($ getNews-> title)> 60)? substr ($ getNews-> title, 0, strpos ($ getNews-> title, '', 60)) .'... ': $ getNews-> title; $ zF = ($ x% 2 == 0)? "tdunkel": "thell"; echo '<tr> <td style = "height: 25px;" class = "'. $ zF.'"> '. $ getNews-> id.' </td> <td class = "'. $ zF.'"> '. getDatum ($ getNews-> datum).' </td> <td class = "'. $ zF.'"> <a href="index.php?s=admin&a=news_edit&id='.$getNews-> id. '">'. $ ntitle. '</a> < / td> <td class = "'. $ zF.'"> '. $ newsKategorien [$ getNews-> category].' </td> <td class = "'. $ zF.'"> <img src = "'. $ nWichtig.'" alt = "wichtig" /> </td> <td class = "'. $ zF.'"> <img src = "'. $ nAnzeigen.'" alt = "wichtig" /> </td> <td class = "'. $ zF.'"> <a href="index.php?s=admin&a=news_delete&id='.$getNews-> id. '"> <img src =" ./ img / fail. gif "alt =" delete "/> </a> </td> </tr> '; $ x ++; } ?> </table> <? PHP } else { echo '<p class = "meldung_erro"> You cannot access this area </p>'; } ? Link to comment Share on other sites More sharing options...
IonutRO 936 Posted January 17, 2021 Share Posted January 17, 2021 Wrong names in input values, in the php cehck you have: $_POST ['title'] ; $_POST ['content'] But in the html part you have: <input type="text" size="40" maxlength="200" name="titel" /> <textarea style="resize: none;" rows="5" cols="40" name="inhalt"> The names must match. Link to comment Share on other sites More sharing options...
Rodrigo152 4 Posted January 17, 2021 Author Share Posted January 17, 2021 there is, I fixed it, but the problem still persists. Link to comment Share on other sites More sharing options...
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now