Ik ben weer es aan het prutsen met mysql en dit is wat ik heb.
Vraag is moet ik nog meer doen met dat tabel? En wat moet ik nog veranderen aan de scripts, behalve config.php?
1
2
[code="php"]
- - - -
config.php
- - - -
<?
mysql_connect('localhost','//username\\','//wachtwoord\\');
mysql_select_db('//naam van de db. \\') or die (mysql_error());
?>
- - - -
index.php
- - - -
<?
include('config.php');
?>
<table border="1" width="43%" cellspacing="0" cellpadding="0" bgcolor="#808080">
<tr>
<td width="33%" align="center">Naam</td>
<td width="33%" align="center">E-mail</td>
<td width="33%" align="center">Bericht</td>
</tr>
<?php
$qLid = mysql_query("SELECT voornaam,email,bericht FROM test");
while ($aLid = mysql_fetch_assoc($qLid))
{
?>
<tr>
<td width="33%" bgcolor="#C0C0C0">
<?=$aLid['voornaam']?>
</td>
<td width="33%" bgcolor="#C0C0C0">
<a href="mailto:<?=$aLid['email']?>"><?=$aLid['email']?></a>
</td>
<td width="34%" bgcolor="#C0C0C0">
<p align="center">
<font face="Comic Sans MS" size="2">
<i>
<?=$aLid['bericht']?>
</i>
</font>
</td>
</tr>
<?
} //while afsluiten
mysql_free_result($qLid);
?>
</table>
<?
print "wil jij ook een bericht toevoegen?<br>";
print "<a href=\"berichten.php\">Bericht Toevoegen</a>";
?>
- - - -
berichten.php
- - - -
<?
include('config.php');
if(isset($_POST['verzenden']))
{
$voornaam = addslashes($_POST['voornaam']);
$email = addslashes($_POST['email']);
$bericht = addslashes($_POST['bericht']);
mysql_query("INSERT INTO test (voornaam, email, bericht) VALUES ('".$voornaam."','".$email."', '".$bericht."')") or die (mysql_error());
print "Je bericht is succesvol toegevoegd";
}
else
{
?>
<center>
<form action=" <?=$_SERVER['PHP_SELF']?> " method="POST">
Voornaam: <br><input type="text" name="voornaam"><br />
E-mail: <br><input type="text" name="email"><br />
Bericht: <br><textarea name="bericht" rows="5" cols="30">Typ hier je bericht</textarea><br />
<input type="submit" name="verzenden" value="verzenden">
</form> </center>
<?
}
?>
[/code]