noordean

post.php

Sep 29th, 2016
31
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.70 KB | None | 0 0
  1. <?php
  2. session_start();
  3. require_once('class.php');
  4. $user = new User();
  5. if (!$user->isLoggedIn()) {
  6.     header("Location:login_html.php");
  7. }
  8. echo "Welcome ".$_SESSION['user']."<br>";
  9. echo "<a href='redirect.php'>Logout</a> <br>";
  10. $section = $_GET['section'];
  11. if(isset($_POST['submit'])){
  12.     if(empty($_POST['topic']) || empty($_POST['message'])){
  13.         echo "<p style='color:red'>All fields are required</p>";
  14.     }
  15.     else{
  16.         $message = str_ireplace('stupid', 'silly', $_POST['message']);
  17.         $message = $user->escapeInput($message);
  18.         $topic = $user->escapeInput($_POST['topic']);
  19.         $user->createTopic($topic,$message,$_SESSION['user'],$section);
  20.             header("Location:section.php?section=".$section);
  21.        
  22.     }
  23. }
Add Comment
Please, Sign In to add comment