Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $servername = "localhost";
- $username = "root";
- $password = "edel187211"
- try {
- $conn = new PDO("mysql:host=$servername;dbname=chat", $username, $password);
- $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
- echo "Connection successful"
- }
- catch(PDOException $e)
- {
- echo "Connection failed: " . $e->getMessage();
- }
- if(isset($_POST['text']) && isset($_POST['name']))
- {
- $text = strip_tags(stripslashes($_POST['text']));
- $name = strip_tags(stripslashes($_POST['name']));
- if(!empty($text) && !empty($name))
- {
- $insert = $db->prepare("INSERT INTO messages VALUES('','".$name."','".$text."')");
- $insert->execute();
- echo "<li class = 'cm'><b>".ucwords($name)."</b> - ".$text."</li>";
- }
- }
- ?>
Add Comment
Please, Sign In to add comment