Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [php] Problem z forum
-Gość_kefir-
post
Post #1





Goście







Czy ktos mi pomoze i powie dlaczego posty nie sa dodawane do bazy?

  1. <html>
  2.     <head>
  3.     <title>Forum 3 grupy WSIiE</title>
  4.     </head>
  5.         <body>
  6.         <h2>!! FoRuM DySkuSyJnE  !!</h2>
  7.         <a href="main.php">Wszystkie posty</a>,
  8.         <a href="nowy_post.php">Nowy post</a><hr>
  9.             <?php 
  10.             error_reporting (0);
  11.             //wyswietla formularz i przyjmuje dane, wpisujac nowy post do bazy.
  12.             
  13.             $polaczenie=pg_connect ("host=127.0.0.1 dbname=postgres user=ls password=ddd3") or die ("Nie można połączyć z PostgreSQL");
  14.             
  15.             if ($_POST['co']=='wyslij'){
  16.               $tytul = addslashes(htmlspecialchars ($_POST['tytul']));
  17.               $osoba = addslashes(htmlspecialchars ($_POST['osoba']));
  18.               $tresc = addslashes(nl2br(htmlspecialchars ($_POST['tresc'])));
  19.                   if ($tytul && $osoba && $tresc){ //dopisujemy
  20.                   $zapisz = pg_query("INSERT INTO forum (osoba, tytul , tresc, data, ref) VALUES  ('$osoba', '$tytul', '$tresc', now(),'".$_GET['ref']."')");
  21.                  
  22.                   print 'Wpis został dokonany.<a href="main.php">Księga gości</a>';
  23.                   exit;
  24.                 } else {
  25.                   $tresc2=$_POST['tresc'];
  26.                   $tytul2=$_POST['tytul'];
  27.                   $osoba2=$_POST['osoba'];
  28.                 }
  29.                             
  30.             } elseif ($_GET['ref']>0){
  31.               $wynik = pg_query ($polaczenie, "SELECT osoba, tytul, tresc, data "."FROM forum WHERE nr=".$_GET['ref']);
  32.               if ($wynik && $rekord = pg_fetch_assoc ($wynik)){
  33.                 $tresc = $rekord['tresc']; $tytul = $rekord['tytul'];
  34.                 $tresc = str_replace ("<br />", "", $tresc);
  35.                 $tresc = str_replace ("\n", "\n: ", $tresc); $tresc = ": ".$tresc;
  36.                     if (!(ereg("^Re: ", $tytul))){
  37.                       $tytul = "Re: ".$tytul;
  38.                     }
  39.                     print "<H3>Odpowiedz na post: ".$rekord['tytul']."</H3><P>Wysłany przez ";
  40.                     print "<b>".$rekord['osoba']."</b>,<b>".$rekord['data']."</b></P>".$rekord['tresc']."<br><hr>";
  41.                     
  42.             }
  43.             }
  44.         //grafika od formularza
  45.         
  46.         print "<h3>Wyślij post:</h3>";
  47.         print "<form method=post><input type=\"hidden\" name=\"co\" value=\"";
  48.         print "wyslij\"><input type=\"hidden\" name=\"ref\" value=\"".$_GET['ref']."\">";
  49.         print "<b>Osoba:</b><br><input type=\"text\" name=\"osoba\" ";
  50.         print "<input type=\"text\" name=\"tytul\" value=\"$tytul\" ";
  51.         print "size=60><br><b>tresc:</b><br><textarea name=\"tresc\" ";
  52.         print "rows=10 cols=60>$tresc</textarea><br>\n";
  53.         print "<input type=\"submit\" value=\"Wyslij\">";
  54.         print "</form>";
  55.              ?>
  56.         </body>
  57. </html>
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
-Gość_kefir-
post
Post #2





Goście







Nic nie pomoglo...

Po nacisnieci Wyslij odswierza sie ta strona lecz nic sie nie dzieje.. nie ma wpisow do bazy, ani komunikatu, ze wpis zostal dodany.. Nie wywala tez bledow..

Nie wiem co jest zle.
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 7.10.2025 - 09:25