This repository has been archived by the owner on Apr 30, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlienhe.php
85 lines (80 loc) · 3.44 KB
/
lienhe.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
<?php
session_start();
require_once("./includes/connect.php");
include("./includes/function.php");
include("./includes/header.php");
include("./includes/sidebar-a.php");
?>
<div class="noidung">
<?php
$errors = array();
if (isset($_POST['submit'])) {
//Check Form
if (empty($_POST['txtName'])) {
$errors[] = "txtName";
} else {
$txtName = checkData($_POST['txtName']);
}// end name
if(empty($_POST['txtEmail'])) {
$errors[] = "txtEmail";
} elseif (!preg_match('/^[\w.-]+@[\w.-]+\.[a-zA-Z]{2,6}$/', $_POST['txtEmail'])) {
$errors[] = "wrong_email";
} else {
$txtEmail = checkData($_POST['txtEmail']);
}// end Mail
if (empty($_POST['txtNoidung'])) {
$errors[] = "txtNoidung";
} else {
$txtNoidung = mysql_real_escape_string(trim($_POST['txtNoidung']));
}// end noidung
// Chen vao CSDL
if (empty($errors)) {
$s = "INSERT INTO lienhe(lhe_name, lhe_email, lhe_comment, ngaygui)
VALUES('$txtName', '$txtEmail', '$txtNoidung', NOW())";
$q = mysql_query($s) or die("Không thể chèn !");
if (mysql_affected_rows($dbc) == 1) {
$mess = "<span class='success'>Thành công ! Cảm ơn bạn đã đóng góp ý kiến.</span>";
} else {
$mess = "<span class='error'>Email của bạn không thể gửi, vui lòng thử lại sau !</span>";
}
} else {
$mess = "<span class='error'>Bạn chưa điền đầy đủ thông tin</span>";
}
}// end IF ISSET
?>
<div class="lienhe">
<form id="contact" action="" method="post">
<fieldset>
<legend>Liên hệ</legend>
<?php
if (!empty($mess)) {
echo $mess;
}
?>
<div>
<label for="Name">Họ tên: <span class="required">*</span>
</label>
<input type="text" name="txtName" id="name" value='<?php saveValue('txtName'); ?>' size="20" maxlength="80" tabindex="1" />
<?php checkError($errors, 'txtName', '<span class="warning">Bạn chưa nhập tên !</span>') ?>
</div>
<div>
<label for="email">Email: <span class="required">*</span>
</label>
<input type="text" name="txtEmail" id="email" value='<?php saveValue('txtEmail'); ?>' size="20" maxlength="80" tabindex="2" />
<?php checkError($errors, 'txtEmail', '<span class="warning">Bạn chưa nhập Email !</span>') ?>
<?php checkError($errors, 'wrong_email', '<span class="warning">Email không hợp lệ !</span>') ?>
</div>
<div>
<label for="comment">Nội dung: <span class="required">*</span>
<?php checkError($errors, 'txtNoidung', '<span class="warning">Bạn chưa nhập nội dụng !</span>') ?>
</label>
<div id="contact">
<textarea name="txtNoidung" id="comment" rows="10" cols="45" tabindex="3"></textarea>
</div>
</div>
</fieldset>
<div><input type="submit" name="submit" value="Gửi" /></div>
</form>
</div>
</div><!-- end noidung -->
<?php include("./includes/footer.php"); ?>