-
Notifications
You must be signed in to change notification settings - Fork 0
/
skript.php
34 lines (33 loc) · 1.16 KB
/
skript.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
<?php
if (isset($_POST['submit'])) {
// NEZNASAMPHP
$required = array('name', 'email', 'comment');
$error = false;
foreach($required as $field) {
if (empty($_POST[$field])) {
$error = true;
}
}
if ($error) {
$name = $_POST['name'];
$email = $_POST['email'];
$comment = $_POST['comment'];
echo 'Je potreba vyplnit vsetko';
} else {
$name = strip_tags($_POST['name']);
$email = strip_tags($_POST['email']);
$comment = strip_tags($_POST['comment']);
$fp = fopen("C:/WinNMP/WWW/Projekt.ZMTMO/comments.txt","a");
if (@fwrite($fp, $name. ' ' . '|' . ' '.$email. ' ' . '|' . ' ' .'- napísal - '.$comment. '<br>' . "\n")) {
echo 'Koment bol pridany';
$name = "";
$email = "";
$comment = "";
fclose($fp);
} else {
echo 'Komment nebol pridany';
fclose($fp);
}
}
}
?>