php session_start include modules global php function input_err type g

 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
<?php
session_start();
include("modules/global.php");
function input_err($type) {
global $smarty;
$err = "<img src=\"/img/error.png\" border=\"0\" alt=\"Ошыбка\" />";
$smarty->assign($type.'_err', $err);
}
if(isset($_POST['submit'])) {
if(isset($_SESSION['captcha_keystring']) && $_SESSION['captcha_keystring'] == $_POST['s_code']){
//код с картинки правелен
$name = trim($_POST['name']);
$email = trim($_POST['email']);
$subject = trim($_POST['subject']);
$importance = $_POST['importance'];
$message = $_POST['message'];
if (preg_match("/^(?:[a-z0-9]+(?:[-_]?[a-z0-9]+)?@[a-z0-9]+(?:\.?[a-z0-9]+)?\.[a-z]{2,5})$/i", $email)) {
if($name != '') {
if($subject != '') {
if($message != '') {
//add message to db
} else {
input_err("mess");
}
} else {
input_err("subj");
}
} else {
input_err("name");
}
} else {
input_err("mail");
}
} else {
input_err("key");
}
}
unset($_SESSION['captcha_keystring']);
$s_code = session_name().'='.session_id();
$smarty->assign("s_code", $s_code);
$smarty->display("feedback.tpl");
?>