Jump to content
  • 0

[Site] Publication news


Rodrigo152

Question

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 post

5 answers to this question

Recommended Posts

  • 0

<?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 post
  • 0

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 post
  • 0
  • VIP

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.

spacer.png

Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



  • Activity

    1. 3

      Loading index and waypoint files like GF

    2. 222

      WorldEditor ReMIX

    3. 3

      Loading index and waypoint files like GF

    4. 3

      HWID ban

    5. 0

      Auth problem

    6. 2

      Starting a metin2 server on a VPS ?

    7. 3

      Client afk in background - Effects started to fun faster

  • Recently Browsing

    No registered users viewing this page.

Shoutbox

Shoutbox

Chatroom Rules

 

Join our Discord

A request for help = Shoutbox Ban

Be respectful & Respect the rules

 

×
×
  • Create New...

Important Information

Terms of Use / Privacy Policy / Guidelines / We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.