-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.php
123 lines (113 loc) · 3.18 KB
/
test.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
<?php
$formulier=true;
$err = $nameErr = $fnameErr = $emailErr = $infoErr = '';
$name = $fname = $email = $info = '';
$sqlErr='';
$inhoud='
';
if($_SERVER['REQUEST_METHOD']=='POST')
{
// geopend uit formulier - verwerk formulier
// maak connectie met de database
$conn=false;
$bestand='./connectie.php';
if(file_exists($bestand)) { include($bestand); }
if (!$conn)
{
// geen verbinding met db
$inhoud .= '<p>Could not connect with our database<br>
Try again later</p>';
$formulier = false;
}
else
{
function test_input($data)
{
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
return $data;
}
if(empty($_POST['name']))
{
$nameErr = 'required';
}
else
{
$name = test_input($_POST['name']);
}
if(empty($_POST['fname']))
{
$fnameErr = 'required';
}
else
{
$fname = test_input($_POST['fname']);
}
if(empty($_POST['email']))
{
$emailErr = 'required';
}
else
{
$email = test_input($_POST['email']);
}
if(empty($_POST['info']))
{
$infoErr = 'required';
}
else
{
$info = test_input($_POST['info']);
}
$err=$nameErr.$fnameErr.$emailErr.$infoErr.$sqlErr;
if ($err=='')
{
// alles ok - bewaar geg's in database
$formulier = false;
try
{
$sql='INSERT INTO help (name, familyName, email, info) VALUES (?, ?, ?, ?)';
// $sql="INSERT INTO help (name, familyName, email, info) VALUES ('$name','$fname','$email','$info')";
// $inhoud.= '<input type="hidden name="sql" value="'.$sql.'"><br>';
$res = $conn->prepare($sql);
$res->execute(array($name, $fname, $email, $info));
/*****************************************************************/
//toon bericht over nieuwsbrief
$inhoud.='Dear '.$name.', thanks for letting us know about <br>
your problem we are trying to fix it as soon as possible';
}
catch (Exception $e)
{
$$sqlErr.='<p>Could not connect with our database<br>
Try again later</p>';
$inhoud.= $sqlErr;
} // einde catch
} // einde foutberichten invoer
} // einde connectie ok
} // einde verwerk formulier
else
{
// geopend uit url
} // einde uit url
$inhoud.='
<form method="post" id="form" action="" onsubmit="return checkformm(this)">
<h1 id="ask-title">Drop us a note we will answer as soon as possible</h1>
<h2>Name</h2>
<input type="text" id="name" name="name" required>
<h2>Family name</h2>
<input type="text" id="fname" name="fname" required>
<h2>E-mail</h2>
<input type="text" id="email" name="email" required>
<h2>Write us about your issue</h2>
<textarea name="" cols="30" rows="10" id="info" name="info"></textarea>
<br>
<input type="submit" value="Send">
</form>';
// toon pagina
$bestand="./head.php";
if (file_exists($bestand)) { include($bestand); }
echo $inhoud;
$bestand="./foot.php";
if (file_exists($bestand)) { include($bestand); }
?>