config.php

<?php
$host = ""; // je hostname, meestal localhost
$user = ""; // je username
$pass = ""; // je wachtwoord
$dbas = ""; // je database-naam

// connect naar database
if(mysql_connect($host, $user, $pass)) {
  // selecteer database
  mysql_select_db($dbas) or die(mysql_error());
} else {
  // connecten naar database is mislukt
  echo "Connecten naar database is mislukt.";
  exit;
}
?>

Index.php
<html>
<head>
<meta http-equiv="Content-Language" content="nl-be">
</head>
<body bgcolor="#C0C0C0"><center>
<table border="0" cellspacing="0" cellpadding="0" background="images/interface_13.gif">
	<tr>
		<td valign="top">
		<table border="0"cellspacing="0" cellpadding="0" width="95%"align="right" class="text1">
			<tr>
				<td>Blablablabla.Daarom starten we de petitie.<a href="sign.php">Teken de petitie</a>				</td><br>
			</tr>
			<tr>
				<td>

<?php
////////////////////////////////////////////////
////              Auteur:Finduilas.         ////
////       mathias_lauwyck@hotmail.com      ////
////////////////////////////////////////////////

include 'connect.php'; // Databaseverbinding

if(mysql_result(mysql_query("SELECT COUNT(id) FROM `petitie`"),0) == 0)
//Niemand heeft de petitie getekend
  { 
    echo 'Er heeft nog niemand de petitie getekend.'; 
  } 
else 
  { 
  ?>
<center>
<table class="text1" bgcolor="#000000" > 
<tr> 
<td valign="top" height="21"><font color="#FF0000">Naam:</font></td>
<td valign="top" height="21"><font color="#FF0000">Email:</td>  
</tr>
<?php 
  $qSelect_petitie  = mysql_query('SELECT * FROM `petitie` ORDER BY `id` DESC') or die (mysql_error()); 
  while($apetitie = mysql_fetch_array($qSelect_petitie)) 
    { 
      echo '<tr> 
              <td valign="top"><font color="#FF0000">'.$apetitie['naam'].'</font></td> 
              <td valign="top"><font color="#FF0000">'.$apetitie['email'].'</font></td> 
            </tr>'; 
    } 
     echo '</table></center>'; 
   } 
?> 
			 	</td>
			</tr>
		</table>
		</td>
	</tr>
</table>
</center><br><br>
</body>
</html>
Sign.php:

<?php 
include 'connect.php'; // Databaseverbinding

if($_SERVER['REQUEST_METHOD'] == 'POST' && !empty($_POST)) 
  { 
    $aFouten = array(); 
    if(empty($_POST['naam']))
      { 
        $aFouten[] = 'Je hebt geen naam ingevuld'; 
      } 
    if(empty($_POST['email']))
      { 
        $aFouten[] = 'Je hebt geen email ingevuld'; 
      } 
    if(count($aFouten) != 0) 
      { 
      	echo 'De volgende fouten zijn opgetreden: <br /><br />'; 
         for($Fi = 0; $Fi < count($aFouten); $Fi++) 
          { 
           echo $aFouten[$Fi].'<br />'; 
              } 
            echo '<br />Klik <a href="javascript:history.go(-1);">hier</a> om terug te keren'; 
          } 
        else 
         {
			if(!mysql_query("INSERT INTO petitie (naam,email) VALUES ('".addslashes($_POST['naam'])."','".addslashes($_POST['email'])."')")
			{
     			echo "Er ging iets fout!: ".mysql_error()."";
			}
			else
			{
    		mysql_query("INSERT INTO petitie (naam,email) VALUES ('".addslashes($_POST['naam'])."','".addslashes($_POST['email'])."')")
			echo 'Bedankt om deel te nemen aan de Petitie!<a href="index.php">Terug naar het begin</a>'
			}
         } 
       
  } 
else 
  {
?>
<form action=" <?=$_SERVER['PHP_SELF']?> " method="POST">
Naam: <input type="text" name="naam"><br /> 
Email: <input type="text" name="email"><br /> 
<input type="submit" name="verzenden" value="Tekenen"> 
</form> 
<? 
  } 
?>

