This repository was archived by the owner on Feb 8, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathnote_add.php
57 lines (57 loc) · 2.34 KB
/
note_add.php
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
<?php
session_start();
include('exec/dbconnect.php');
include('exec/check_user.php');
if($_SESSION['loginin'] == "1"){
if($_POST['note_create']){
if($_POST['note_name'] == NULL){
echo '<meta charset="utf-8">мы не можем для вас создать безымянную группу, извините.';
exit();
}
$_POST['note_name'] = htmlentities($_POST['note_name'],ENT_QUOTES);
$_POST['note_about'] = htmlentities($_POST['note_about'],ENT_QUOTES);
$_POST['note_name'] = str_replace(array("\r\n", "\r", "\n", "<", ">"), '<br>', $_POST['note_name']);
$_POST['note_about'] = str_replace(array("\r\n", "\r", "\n", "<", ">"), '<br>', $_POST['note_about']);
$q = "INSERT INTO `note` (`id`, `name`, `text`, `aid`, `date`) VALUES (NULL, '".$_POST['note_name']."', '".$_POST['note_about']."', '".$_SESSION['id']."', '".time()."')";
$q1 = $dbh1->prepare($q);
$q1 -> execute();
$q1->fetch();
$q2 = $dbh1->prepare("SELECT * FROM note WHERE `text` = '".$_POST['note_about']."' AND `aid` = '".$_SESSION['id']."'");
$q2->execute();
$clb = $q2->fetch();
$clb = $clb['id'];
header("Location: note".$clb);
exit();
}
include('exec/header.php');
include('exec/leftmenu.php');
?>
<div>
<div id="content-infoname"><b>Создание заметки</b></div>
<form action="note_add.php" method="post">
<table border="0" style="font-size:11px;">
<tr><td style="width:150px;"><div style="float:right;padding-right:7px;color:#777;">Название заметки:</div></td><td><input id="text" style="width:380px;" name="note_name" maxlength="255"></td></tr>
<tr><td style="width:150px;"><div style="float:right;padding-right:7px;color:#777;">Содержание:</div></td><td><textarea style="min-width:380px;max-width:380px;" id="text" nkeypress="return isNotMax(this)" name="note_about"></textarea></td></tr>
<script type="text/javascript">
function isNotMax(oTextArea) {
return oTextArea.value.length <= oTextArea.getAttribute('maxlength');
}
</script>
</table><br>
<div style="margin-left:157px;"><input type="submit" id="button" value="Опубликовать" name="note_create"></div>
</form>
</div>
</div>
</div>
</div>
<div>
<? include('exec/footer.php'); ?>
</div>
</div>
</body>
</html>
<?php }else if($_SESSION['loginin'] != "1"){
echo '<meta charset="utf-8">Пожалуйста, авторизируйтесь.<meta http-equiv="refresh" content="3;blank/../">';
exit();
}
?>