Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- if(isset($_POST['extract']))
- {
- $servername = "***";
- $username = "***";
- $password = "***";
- $dbname = "***";
- $tekst=$_POST['extract'];
- try {
- $conn = new PDO("mysql:host=$servername;dbname=$dbname", $username, $password);
- // set the PDO error mode to exception
- $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
- // prepare sql and bind parameters
- $stmt = $conn->prepare("INSERT INTO history (id, name, message, data)
- VALUES (NULL, :name, :message, :data)");
- $stmt->bindParam(':name', $name);
- $stmt->bindParam(':message', $message);
- $stmt->bindParam(':data', $data);
- $name = "Name";
- $message = $_POST['extract'];
- $data = "2018-08-08";
- $stmt->execute();
- echo "New records created successfully";
- }
- catch(PDOException $e)
- {
- echo "Error: " . $e->getMessage();
- }
- $conn = null;
- }
- ?>
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="utf-8">
- <link rel="stylesheet" type="text/css" href="style.css">
- <link href="https://fonts.googleapis.com/css?family=Roboto+Condensed" rel="stylesheet">
- <title>Test</title>
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- </head>
- <body>
- <div class="chatDiv">
- <div class="chat" id="chatBox">
- </div>
- <form name="textBoxForm" method="POST">
- <textarea name="extract" id="textBox1"></textarea>
- <input name="submit" type="submit" class="show" onclick="show()" value="Wyślij" id="btn">
- </form>
- </div>
- <script type="text/javascript" src="main.js"></script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement