Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- INDEX.PHP
- <!DOCTYPE html>
- <html>
- <head>
- <title>Sample</title>
- <link rel="stylesheet" type="text/css" href="style.css" />
- <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>
- </head>
- <body>
- <textarea id="input"></textarea>
- <br />
- <input id="send" type="button" value="send" />
- <script>
- $("#send").click(function(){
- $("#input").val();
- $.ajax({
- type: 'POST',
- url: "test.php",
- data: "text="+$("#input").val(),
- success: function(data){ console.log(data); }
- });
- });
- </script>
- </body>
- </html>
- TEST.PHP
- <?php
- $text = $_POST["text"];
- $db = new PDO('pgsql:dbname=test;host=localhost;user=postgres;password=123');
- $res = $db->query("insert into test values('$text')");
- echo "ok";
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement