daily pastebin goal
68%
SHARE
TWEET

Untitled

a guest Oct 16th, 2017 70 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <? PHP
  2. //Process the POST data in prepration to write to SQL database.
  3. $_POST['chat_input'] = $input;  
  4. $time = date("Y-m-d H:i:s");    
  5. $ip = $_SERVER['REMOTE_ADDR'];  
  6. $name = $_SESSION['username'];    
  7. $servername = "localhost";
  8. $username = "id3263427_chat_user";
  9. $password = "Itudmenif1!Itudmenif1!";
  10. $dbname = "id3263427_chat_user";
  11. $id = "NULL";
  12. // Create connection
  13. $conn = mysqli_connect($servername, $username, $password, $dbname);
  14. if($link === false){die("ERROR: Could not connect. " .  mysqli_connect_error());}
  15. $sql  = 'INSERT INTO `chat` (`id`, `username`, `ip`, `timestamp`,   `message`)  VALUES ('$id','$name', '$ip', '$time', '$input')';
  16. if(mysqli_query($link, $sql)){ mysqli_close($conn);
  17. header('Location: ../protected_page.php');} else{
  18. echo "ERROR: Could not able to execute $sql. " . mysqli_error($link);}
  19. ?>
  20.    
  21. <form action="/process.php" method="post" id="chat">
  22. <b> Send A Message (500 Character Max):</b><br>
  23. <textarea name="chat_input" form="chat" size="500"></textarea>
  24. <input type="submit" value=submit>
  25. </form>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top