SuperMonkey

new_message.php

Jul 2nd, 2012
196
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.49 KB | None | 0 0
  1. <?php
  2.     session_start();
  3.  
  4.     try {
  5.         $bdd = new PDO("mysql:host=localhost;dbname=chat", "root", "************");
  6.     }
  7.    
  8.     catch (Exception $e) {
  9.         die ($e->getMessage());
  10.     }
  11.    
  12.     if(strlen($_POST["pseudo"]) < 25 AND strlen($_POST["pseudo"]) > 4 AND strlen($_POST["message"]) > 0) {
  13.         $req = $bdd->prepare("INSERT INTO messages VALUES (NULL, ?, ?)");
  14.         $req->execute(array($_POST["pseudo"], $_POST["message"]));
  15.         $_SESSION["pseudo"] = $_POST["pseudo"];
  16.     }
  17.    
  18.     header("Location:index.php");
  19.    
  20.  
  21. ?>
Advertisement
Add Comment
Please, Sign In to add comment