-
Notifications
You must be signed in to change notification settings - Fork 3
/
contactus.php
144 lines (118 loc) · 3.66 KB
/
contactus.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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
<html>
<head>
<link href="newpost.css" rel="stylesheet" type="text/css">
<link rel="stylesheet" href="css/bootstrap.css">
<link href="boilerplate.css" rel="stylesheet" type="text/css">
<link href="portfolioResponsive.css" rel="stylesheet" type="text/css">
<link href="portfolioStyle.css" rel="stylesheet" type="text/css">
<script src="respond.min.js"></script>
</head>
<body></style>
<!--This Is Body-->
<?php
include("topmenu.php");
?>
<div class='post_body'>
<form class="basic-grey" action='contactus.php' method='POST'>
<table style='margin-left:30%;margin-top:10' >
<tr height='20'>
<td colspan='2' ><center><img src='images/contactus.jpg' width='390' height='150'></center></td>
</tr>
<tr><td></td></tr>
<tr>
<td align='right'> Your Email</td>
<td><input type='email' size='38' name='email' style="border: 1px solid #DADADA;
color: #888;
height: 30px;
margin-bottom: 16px;
margin-right: 6px;
margin-top: 2px;
outline: 0 none;
padding: 3px 3px 3px 5px;
width: 70%;
font-size: 12px;
line-height:15px;
box-shadow: inset 0px 1px 4px #ECECEC;
-moz-box-shadow: inset 0px 1px 4px #ECECEC;
-webkit-box-shadow: inset 0px 1px 4px #ECECEC;"></td>
</tr>
<!--for adding extra spaces between table lines-->
<tr><td></td></tr>
<tr><td></td></tr>
<tr>
<td align='right'>Subject</td>
<td><input type='text' name='subject' size='38'></td>
</tr>
<tr><td></td></tr>
<tr><td></td></tr>
<tr>
<td align='right'>Message</td>
<td><textarea name='message' cols='40' rows='10'></textarea></td>
</tr>
<tr><td></td></tr>
<tr><td></td></tr>
<tr>
<td align='right' ></td>
<td>
<img src='generate.php' >
<textarea name='source' cols='10' rows='2' placeholder='write number here' maxlength='4'></textarea>
<!--<a ><img src='images/refresh.jpg' width='25' height='25'></a>-->
</td>
</tr>
<tr><td></td></tr>
<tr><td></td></tr>
<tr>
<td></td>
<td style='float:right'><input type='submit' name='sendemail' id="submit"value='Submit'></td>
</tr>
</table>
</form>
</div>
<?php
if(isset($_POST['sendemail'])){
$conn=new mysqli("localhost","root",null,"sahara");
if($conn->connect_error){
die("reeor in database connectivity");
}
$email=htmlentities(mysqli_real_escape_string($conn,$_POST['email']));
$subject=htmlentities(mysqli_real_escape_string($conn,$_POST['subject']));
$message=htmlentities(mysqli_real_escape_string($conn,$_POST['message']));
$source=htmlentities(mysqli_real_escape_string($conn,$_POST['source']));
$count=0;
//// 1:checking all fields are not empty
if(!empty($email)&&!empty($subject)&&!empty($message)&&!empty($source)){
if(strlen($email)<30){
$count++;
}else{
echo '<center><h1>Email length must be less than 30 characters</h1></center><br>';
}
if(strlen($subject)<100){
$count++;
}else{
echo '<center><h1>Subject length must be less than 100 characters</h1></center><br>';
}
if(strlen($message)<1000){
$count++;
}else{
echo '<center><h1>Message length must be less than 1000 characters</h1></center><br>';
}
///2;checking that all the above conditions are true
if($count==3){
@session_start();
if($source==$_SESSION['secure']){
$count++;
}else{
echo '<center><h1>Code Not Match.</h1></center><br>';
}
///2 end
}
///3:after checking that all the fields are corretly filled
if($count==4){
$sql = "INSERT INTO `comments` (`comment_id`, `post_id`, `comments`, `user_id`) VALUES (NULL, \'1\', \'add\', \'1\')";
}//3 end
//1 end
}else{
echo '<h1><center>All Fields Must Be filled.</h1></center>';
}
}//isset sendmail end
?>