fork download
  1. <!DOCTYPE HTML>
  2. <html>
  3. <head>
  4. </head>
  5. <body>
  6. <?php
  7. if ($_SERVER['REQUEST_METHOD'] === 'POST') {
  8. $user = 'test';
  9. $password = 'test';
  10. $db = new PDO('mysql:host=127.0.0.1;dbname=testdb;charset=UTF8', $user, $password);
  11.  
  12.  
  13. $username = $_POST['username'];
  14. $message = $_POST['message'];
  15.  
  16. if ($username != "" && $message != "") {
  17. $stmt = $db->prepare('INSERT INTO posts SET username = ?, message = ?');
  18. $stmt->execute(array($username, $message));
  19. }
  20.  
  21. $db = null;
  22. }
  23.  
  24. header("Location: /index.php");
  25. ?>
  26. </body>
  27. </html>
Success #stdin #stdout #stderr 0.01s 20520KB
stdin
Standard input is empty
stdout
<!DOCTYPE HTML>
<html>
    <head>
    </head>
    <body>
            </body>
</html>
stderr
PHP Notice:  Undefined index: REQUEST_METHOD in /home/h3e7Tj/prog.php on line 7
PHP Warning:  Cannot modify header information - headers already sent by (output started at /home/h3e7Tj/prog.php:6) in /home/h3e7Tj/prog.php on line 24