*Struktura bazy:
wpis: `id` int(11) | `user_id` int(3) | `title` char(50) | `content` text | `data` date
*Połączenie z bazą jest.
*Zmienne post oraz z sesji poprawne
*Błędów żadnych nie wywala
Może ktoś rzuci świeżym okiem i od razu wychwyci

<h3>Dodaj wpis</h3> <?PHP function form(){ echo' <div id="wpis_form"> <form action="index.php?page=new" method="post"> <input type="text" name="title" placeholder="Tytuł" required maxlength="30"><br> <textarea name="content" placeholder="Treść" maxlength="500" required></textarea><br> <input type="submit" name="sent" value="Dodaj wpis"> </form> </div> '; } class dodajWpis extends Connect{ function Length($title,$content){ return true; } } function ifNotExists($title){ $zap=$this->db->prepare("SELECT id FROM wpisy WHERE title=:title"); $zap->bindValue(':title', $title, PDO::PARAM_STR); $zap->execute(); if($zap->rowCount()==0){ return true; } } function getId($title){ $zap=$this->db->prepare("SELECT id FROM wpisy WHERE title=:title"); $zap->bindValue(':title', $title, PDO::PARAM_STR); $zap->execute(); return $zap->fetch()['id']; } function dodaj($title,$content,$user_id){ $query = $this->db->prepare("INSERT INTO wpisy VALUES(null, '$user_id', :title, :content, CURDATE()"); $query -> bindValue(':title', $title, PDO::PARAM_STR); $query -> bindValue(':content', $content, PDO::PARAM_STR); $query -> execute(); } } $o=new dodajWpis(); { { if($o->Length($title,$content)) { if($o->ifNotExists($title)) { $user_id=$_SESSION["user_id"]; $o->dodaj($title,$content,$user_id); } else{ form(); } } else{ form(); } } else{ form(); } } else{ } ?>