Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- session_start();
- $local = "localhost";
- $login = "root";
- $pass = "root";
- $name = "forum";
- $link = mysqli_connect($local,$login,$pass,$name);
- $slug = $params['topicSlug'];
- $topic = str_replace("-",' ',$slug);
- if(!empty($_POST['title']) && !empty($_POST['content'])){
- $title = $_POST['title'];
- $content = $_POST['content'];
- if(preg_match("#[a-zA-Z_-]{0,30}#",$title)){
- $query = mysqli_query($link,"SELECT * FROM fast WHERE title='$title'");
- $test = mysqli_fetch_assoc($query);
- if(empty($test)){
- $fastSlug = $title;
- $fastSlug = str_replace(" ","-",$fastSlug);
- $query = mysqli_query($link,"SELECT * FROM topics WHERE topic_name = '$topic'");
- $res = mysqli_fetch_assoc($query);
- $topic_id = $res['id'];
- $query = mysqli_query($link,"INSERT INTO fast SET slug='$fastSlug',title='$title',content = '$content',topic_id='$topic_id'");
- }
- }
- }
- if($_SESSION['auto'] === true){
- $query = mysqli_query($link,"SELECT * FROM fast
- LEFT JOIN topics ON topics.id = fast.topic_id
- WHERE topic_name = '$topic'") or die(mysqli_error($link));
- $data = [];
- while($row = mysqli_fetch_assoc($query)){
- $data[] = $row;
- };
- $content = '';
- foreach($data as $value){
- $content .= "<a href='/main/".$slug."/".$value['title']."'>".$value['title']."</a></br>";
- }
- $page = [
- 'title' => 'wall',
- 'content' => $content
- ];
- ?>
- <form action="" method="POST">
- <input name="title" placeholder="Title"></br>
- <textarea name="content"></textarea></br>
- <input type='submit'></br>
- </form>
- <?php
- return $page;
- } else {
- header("Location: /auto");
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement