login  Naam:   Wachtwoord: 
Registreer je!
 Scripts:

Scripts > PHP > Gastenboeken > Gastenboek (beginners)

Gastenboek (beginners)

Auteur: thajunk - 22 februari 2005 - 16:03 - Gekeurd door: Joel - Hits: 14422 - Aantal punten: 1.50 (2 stemmen)



Uitleg
------
*Downloaden
*Uitpakken
*Config.php aanpassen
*Create tabel in je .db
*uploaden

- - - - - -
Db. tabel
- - - - - -
CREATE TABLE `test` (
`voornaam` varchar(10) NOT NULL default '0',
`email` varchar(25) NOT NULL default '0',
`bericht` text NOT NULL
) TYPE=MyISAM;


Code:
- - - -
config.php
- - - -
  1. <?
  2.  
  3. mysql_connect('localhost','//username\\','//wachtwoord\\');
  4. mysql_select_db('//naam van de db. \\') or die (mysql_error());
  5. ?>


- - - -
index.php
- - - -
  1. <?
  2. include('config.php');
  3. ?>
  4. <table border="1" width="43%" cellspacing="0" cellpadding="0" bgcolor="#808080">
  5. <tr>
  6. <td width="33%" align="center">Naam</td>
  7. <td width="33%" align="center">E-mail</td>
  8. <td width="33%" align="center">Bericht</td>
  9. </tr>
  10. <?php
  11. $qLid = mysql_query("SELECT voornaam,email,bericht FROM test");
  12. while ($aLid = mysql_fetch_assoc($qLid))
  13. {
  14. ?>
  15. <tr>
  16. <td width="33%" bgcolor="#C0C0C0">
  17. <?=$aLid['voornaam']?>
  18. </td>
  19. <td width="33%" bgcolor="#C0C0C0">
  20. <a href="mailto:<?=$aLid['email']?>"><?=$aLid['email']?></a>
  21. </td>
  22. <td width="34%" bgcolor="#C0C0C0">
  23. <p align="center">
  24. <font face="Comic Sans MS" size="2">
  25. <i>
  26. <?=$aLid['bericht']?>
  27. </i>
  28. </font>
  29. </td>
  30. </tr>
  31. <?
  32. } //while afsluiten
  33. ?>
  34. </table>
  35. <?
  36. print "wil jij ook een bericht toevoegen?<br>";
  37. print "<a href=\"berichten.php\">Bericht Toevoegen</a>";


- - - -
berichten.php
- - - -


  1. <?
  2. include('config.php');
  3.  
  4. if(isset($_POST['verzenden']))
  5. {
  6.  
  7. $voornaam = addslashes($_POST['voornaam']);
  8. $email = addslashes($_POST['email']);
  9. $bericht = addslashes($_POST['bericht']);
  10.  
  11. mysql_query("INSERT INTO test (voornaam, email, bericht) VALUES ('".$voornaam."','".$email."', '".$bericht."')") or die (mysql_error());
  12.  
  13. print "Je bericht is succesvol toegevoegd";
  14. }
  15. else
  16. {
  17. ?>
  18. <center>
  19. <form action=" <?=$_SERVER['PHP_SELF']?> " method="POST">
  20. Voornaam: <br><input type="text" name="voornaam"><br />
  21. E-mail: <br><input type="text" name="email"><br />
  22. Bericht: <br><textarea name="bericht" rows="5" cols="30">Typ hier je bericht</textarea><br />
  23. <input type="submit" name="verzenden" value="verzenden">
  24. </form> </center>
  25. <?
  26. }
  27. ?>
Download code! Download code (.txt)

Download dit script!
 Stemmen
Niet ingelogd.

 Reacties
Post een reactie
Lees de reacties (9)
© 2002-2024 Sitemasters.be - Regels - Laadtijd: 0.04s