(u05917ya.bget.ru) ver 0.1.1

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
<html>
<head>
<title>Testing startup</title>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1251">
</head>
<body>
<h3><center>_Melchiors suffer page! /ver 0.1.1/ </center></h3><br>
<form action="index.php">
<textarea name="txtName" [cols="35"] [rows="10"] wrap="Virtual">
there
</textarea>
<input type="submit" value="Отправить">
</form>
<?php
function _mesg($message){
#echo "<b>debug info:</b> <i>".$message."</i><br>";
}
_mesg("there start script");
_mesg("excuse for debug messages, it's for me, yeah /chagirov loh azaza/");
_mesg("connect to MySQL db");
$host = "host"; $user = "user"; $pass = "pass";
$database = 'db'; $table = 'tb';
$link = mysql_connect($host, $user, $pass) or die(_mesg(mysql_error()));
mysql_select_db($database) or die(_mesg(mysql_error()));
_mesg("all right");
_mesg("start processing GET-method data");
$text = $_GET['txtName'];
if (strlen($text) > 0 && $text != "there") {
_mesg($text);
// Обрабатываем и пишем в ДБ
$repeat = 0;
$q = mysql_query("SELECT * FROM ".$table);
$l = mysql_num_rows($q);
for ($i=$l; $i > 0; $i = $i - 1) {
$f = mysql_fetch_array($q);
if ($text == $f[TEXT]) { $repeat = 1; }
}
if ($repeat == 0) {
$l += 1;
mysql_query('INSERT INTO '. $table .' (NUMBER, TEXT)
VALUES ("'.$l.'","'.$text.'")') or die(_mesg(mysql_error()));
} else { _mesg("error : repeated message"); }
} else {
_mesg("error : empty message or example message");
// Выводим все ошибачки
}
_mesg("outputing messages");
$q = mysql_query("SELECT * FROM ".$table);
$l = mysql_num_rows($q);
for ($i=$l; $i > 0; $i = $i - 1) {
$f = mysql_fetch_array($q);
echo " ".$f[NUMBER]." : ". $f[TEXT];
echo "<br>";
}
_mesg("close connection with DB");
mysql_close();
?>
</body>
</head>