-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontact.php
76 lines (63 loc) · 1.39 KB
/
contact.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
<?php
session_start();
if(!isset($_SESSION['username'])){
header("Location: login.php");
exit();
}
include("mysqli_connect.php");?>
<html>
<meta charset="UTF-8">
<head>
<title>Contact</title>
</head>
<body>
<center>
<h2>Contact Form</h2>
</center>
<ul>
<li><a href="index.php">Index</a></li>
<li><a href="contact.php">Contact</a></li>
<li><a href="logout.php">Logout</a></li>
</ul>
<?php
if($_POST){
$errors=array();
if(!empty($_POST['name'])){
$name=$_POST['name'];
}else{
$errors['name']='Adio Name';
}
if(!empty($_POST['email'])){
$email=$_POST['email'];
}else{
$errors['email']='Adio email';
}
if(!empty($_POST['msg'])){
$msg=$_POST['msg'];
}else{
$errors['msg']='Adio msg';
}
if(empty($errors)){
$q="INSERT INTO contact(name,email,msg) VALUES ('$name','$email','$msg')";
$r=mysqli_query($dbc,$q);
echo '<p><b>To minima kataxorithike me epitixeia<b></p>';
}else{
foreach($errors as $value){
echo "<p><b>Error:</b><u> $value</u></p>";
}
}
}
?>
<fieldset><legend>Contact</legend>
<form action="contact.php" method="post">
Name: <input type="text" name="name" >
<br>
Email: <input type="text" name="email" value="<?php echo $_SESSION['email']?>">
<br>
<textarea rows="4" cols="50" name="msg"></textarea>
<br>
<input type="submit" value="Send">
</form>
</fieldset>
</body>
</html>