simpele-weblog
--------------------------------------------------
weblog.php
---------------------------------------------------
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
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
<?php
//maak connectie met je eigen database
mysql_connect("localhost", "USER", "Passwordt");
mysql_select_db("Naamdatabase");
echo $query;
echo mysql_query($query);
//}
//
$query = "SELECT * FROM weblog ORDER BY id DESC";
$result = mysql_query($query);
while($row=mysql_fetch_assoc($result)){
//hier wordt datum naar NL omgezet
$date = $row['postdate'];
$datesplit = split('-',$date);
$maanden = array('jan','feb','maart','april','mei','juni','juli','aug','sep','okt','nov','dec');
$newDate = ($datesplit[2]*1)."-".$maanden[$datesplit[1]-1]."-".$datesplit[0];
//hier vindt uitvoering plaats
echo "<table border='1' cellspacing='0' cellpadding='0' width=70%>";
echo "<tr><td width=70%>".$row['title']."</td><td align='right' width=30%>".$newDate."</td></tr>";
echo "<tr><td width=70% colspan=4>".$row['tekst']."</td>";
echo "<br />";
echo "<tr><td width=100% colspan=4>".$row['name']."</td></tr>";
echo "</table>";
}
?>
//maak connectie met je eigen database
mysql_connect("localhost", "USER", "Passwordt");
mysql_select_db("Naamdatabase");
echo $query;
echo mysql_query($query);
//}
//
$query = "SELECT * FROM weblog ORDER BY id DESC";
$result = mysql_query($query);
while($row=mysql_fetch_assoc($result)){
//hier wordt datum naar NL omgezet
$date = $row['postdate'];
$datesplit = split('-',$date);
$maanden = array('jan','feb','maart','april','mei','juni','juli','aug','sep','okt','nov','dec');
$newDate = ($datesplit[2]*1)."-".$maanden[$datesplit[1]-1]."-".$datesplit[0];
//hier vindt uitvoering plaats
echo "<table border='1' cellspacing='0' cellpadding='0' width=70%>";
echo "<tr><td width=70%>".$row['title']."</td><td align='right' width=30%>".$newDate."</td></tr>";
echo "<tr><td width=70% colspan=4>".$row['tekst']."</td>";
echo "<br />";
echo "<tr><td width=100% colspan=4>".$row['name']."</td></tr>";
echo "</table>";
}
?>
--------------------------------------------------
toevoegen.php
---------------------------------------------------
<head>
<title>log toevoegen</title>
</head>
<body>
<form action=Thome.php method=POST>
<table>
<input type="hidden" name="submit" value="yes">
title: <textarea rows="1" name="title" cols="42">Unkwown</textarea><br>
tekst: <textarea rows="1" name="tekst" cols="42">Unkwown</textarea><br>
name: <textarea rows="1" name="postby" cols="42">Jan Willem</textarea><br>
<input type="submit" vale=" Voeg toe ">
</table>
</form>
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
<?php
if ($_POST['submit']) {
$title = addslashes($_POST['titel']);
$tekst = addslashes($_POST['tekst']);
$postdate = addslashes($_POST['postdate']);
$name = addslashes($_POST['name']);
mysql_connect("localhost", "usrname", "password");
mysql_select_db("database");
$sql = "insert into home(title,tekst,postdate,name)
values('$title','$tekst',NOW(),'$name')";
mysql_query($sql) or die("Oops...");
echo "bericht toegevoegd.";
}
?>
if ($_POST['submit']) {
$title = addslashes($_POST['titel']);
$tekst = addslashes($_POST['tekst']);
$postdate = addslashes($_POST['postdate']);
$name = addslashes($_POST['name']);
mysql_connect("localhost", "usrname", "password");
mysql_select_db("database");
$sql = "insert into home(title,tekst,postdate,name)
values('$title','$tekst',NOW(),'$name')";
mysql_query($sql) or die("Oops...");
echo "bericht toegevoegd.";
}
?>