Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <body>
- <title>[pts] Paste Text Service</title>
- <?php
- function dbConnect() {
- $host='localhost';
- $database='paste';
- $user='root';
- $pass='';
- mysql_connect($host, $user, $pass);
- mysql_select_db($database);
- }
- function read ($id) {
- $result = mysql_query("SELECT * FROM paste_text WHERE id = '$id'");
- $tmp = mysql_fetch_assoc($result);
- return $tmp['text'];
- }
- function write ($id, $text) {
- mysql_query("INSERT INTO paste_text (id, text) VALUES ('$id','$text')");
- } ?>
- <? function inputForm($text) { ?>
- <form action="<?=$_SERVER['SCRIPT_NAME']?>" method="POST">
- <textarea name=textarea cols=45 rows=6><? echo $text; ?></textarea>
- <br><input type="submit" name="paste" value="Вставить">
- </form>
- <? }
- function outputForm($text) { ?>
- <form action="<?=$_SERVER['SCRIPT_NAME']?>" method="POST">
- <textarea name=textarea cols=45 rows=6><? echo $text; ?></textarea>
- <br><input type="submit" name="paste" value="Вставить">
- </form>
- <? }
- if (!isset($_REQUEST['paste'])) {
- dbConnect();
- echo read($_GET['id'])."<br>";
- inputForm("");
- } else {
- dbConnect();
- $idUser = uniqid ('');
- write($idUser, $_REQUEST['textarea']);
- echo "готово";
- inputForm($_REQUEST['textarea']);
- }
- ?>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement