add.php
Gesponsorde koppelingen
PHP script bestanden
Code (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
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
<?php
include 'config.php';//Db settings
if($_SERVER['REQUEST_METHOD'] == 'POST'){//Form is verzonden
if (!empty($_POST['text'])) {
if (!empty($_POST['link'])) {
$result = mysql_query("INSERT INTO
menu
(text, link, class)
VALUES
('".mysql_real_escape_string($_POST['text'])."',
'".mysql_real_escape_string($_POST['link'])."',
'".mysql_real_escape_string($_POST['class'])."')
");//Query
if (!$result) //Controle of Query goed gaat.
{
echo "De query geeft een error: " . mysql_error(); //Query gaat fout
exit;//Niks meer van code uitvoeren
}
else
{
echo 'Je item is succesvol toegevoegt!';//Er is niks fout gegaan!
}
}
else
{
echo 'Link is verplicht!';//Link is 0
}
}
else
{
echo 'Text is verplicht!';//Text is 0
}
}//Eind post
?>
include 'config.php';//Db settings
if($_SERVER['REQUEST_METHOD'] == 'POST'){//Form is verzonden
if (!empty($_POST['text'])) {
if (!empty($_POST['link'])) {
$result = mysql_query("INSERT INTO
menu
(text, link, class)
VALUES
('".mysql_real_escape_string($_POST['text'])."',
'".mysql_real_escape_string($_POST['link'])."',
'".mysql_real_escape_string($_POST['class'])."')
");//Query
if (!$result) //Controle of Query goed gaat.
{
echo "De query geeft een error: " . mysql_error(); //Query gaat fout
exit;//Niks meer van code uitvoeren
}
else
{
echo 'Je item is succesvol toegevoegt!';//Er is niks fout gegaan!
}
}
else
{
echo 'Link is verplicht!';//Link is 0
}
}
else
{
echo 'Text is verplicht!';//Text is 0
}
}//Eind post
?>
<form name="input" action="" method="post">
MenuText: <input type="text" name="text" required="required"/><br/>
MenuLink: <input type="text" name="link" required="required"/><br>
MenuClass: <input type="text" name="class" /></br>
<input type="submit" value="Submit" />
</form>
<a href="edit.php">Menu aanpassen</a> | <a href="menu.php">Menu bekijken</a>