:: [url=http://84.105.39.21/scripts/memo/memo.sql]memo.sql[/url] ::

[code]CREATE TABLE memo (
	id			int unsigned				not null				auto_increment			primary key,
	memo			varchar(150)				not null,
	wanneer			datetime				not null				default '0000-00-00 00:00:00'
);[/code]

:: [url=http://84.105.39.21/scripts/memo/config.phps]config.php[/url] ::

<?php

ini_set('display_errors', 0); error_reporting(E_ALL);

mysql_connect('localhost', 'user', 'pass') or die(mysql_error());
mysql_select_db('database') or die(mysql_error());

?>

:: [url=http://84.105.39.21/scripts/memo/header.phps]header.php[/url] ::

[code]<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

	<head>

		<title>Memo</title>

			<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />

	</head>

<body>[/code]

:: [url=http://84.105.39.21/scripts/memo/footer.phps]footer.php[/url] ::

[code]</body>
</html>[/code]

:: [url=http://84.105.39.21/scripts/memo/index.phps]index.php[/url] ::

<?php

include('config.php');

include('header.php');

$sql_a = mysql_query("SELECT id, memo, wanneer FROM memo");

if($sql_a && mysql_num_rows($sql_a) > 0) {

	echo '<h2>Memo\'s</h2>'."\n";

	echo '<table style="padding: 0px 40px 0px 84px; width: 600px;">'."\n";

	while($res_a = mysql_fetch_array($sql_a)) {

		echo '	<tr>'."\n".'		<td>'."\n".'		'.$res_a['memo']."\n".'		</td>'."\n".'		<td>'."\n".'		<a href="verwijder.php?id='.$res_a['id'].'">verwijder</a>'."\n".'		</td>'."\n".'	</tr>'."\n";

	}

	echo '</table>'."\n";
	echo '<p>Memo <a href="toevoegen.php">toevoegen</a></p>'."\n";

} else {

	if(mysql_error()) {

		echo mysql_error();

	} else {

		echo '<h2>Geen Memo\'s</h2>'."\n";
		echo '<p>Er zijn nog geen memo\'s. Klik <a href="toevoegen.php">hier</a> om een memo toe te voegen.<p>'."\n";

	}

}

include('footer.php');

?>

:: [url=http://84.105.39.21/scripts/memo/toevoegen.phps]toevoegen.php[/url] ::

<?php

include('config.php');

include('header.php');

if(!empty($_POST['submit']) && $_POST['submit'] == 'toevoegen') {

	if(!empty($_POST['memo']) && strlen(trim($_POST['memo'])) > 1) {

		mysql_query("INSERT INTO memo (memo, wanneer) VALUES ('".mysql_real_escape_string($_POST['memo'])."', now())");

		if(mysql_affected_rows()) {

			if(mysql_error()) {

				echo mysql_error();

			} else {

				echo '<h2>Memo toegevoegt</h2>'."\n";
				echo '<p>Je memo is toegevoegt. klik <a href="index.php">hier</a> om terug te gaan naar de memo\'s.</p>'."\n";

			}

		} else {

			echo '<h2>Niet toegevoegt</h2>'."\n";
			echo '<p>Het was niet gelukt om je memo toe te voegen.</p>'."\n";
			echo '	<fieldset>
		<legend>Memo toevoegen</legend>

			<form method="post" action="toevoegen.php">

					<p>
						<label for="memo" class="align_text">Memo:</label>
						<input id="memo" name="memo" type="text" maxlength="150" />
					</p>

					<p>
						<input name="submit" type="submit" class="s_button" value="toevoegen" />
					</p>

				<br />

			</form>

	</fieldset>'."\n";

		}

	} else {

		echo '<h2>Niet toegevoegt</h2>'."\n";
		echo '<p>Je memo moet uit minstens 2 karakters bestaan.</p>'."\n";
		echo '	<fieldset>
		<legend>Memo toevoegen</legend>

			<form method="post" action="toevoegen.php">

					<p>
						<label for="memo" class="align_text">Memo:</label>
						<input id="memo" name="memo" type="text" maxlength="150" />
					</p>

					<p>
						<input name="submit" type="submit" class="s_button" value="toevoegen" />
					</p>

				<br />

			</form>

	</fieldset>'."\n";

	}

} else {

echo '	<fieldset>
		<legend>Memo toevoegen</legend>

			<form method="post" action="toevoegen.php">

					<p>
						<label for="memo" class="align_text">Memo:</label>
						<input id="memo" name="memo" type="text" maxlength="150" />
					</p>

					<p>
						<input name="submit" type="submit" class="s_button" value="toevoegen" />
					</p>

				<br />

			</form>

	</fieldset>'."\n";

}

include('footer.php');

?>

:: [url=http://84.105.39.21/scripts/memo/verwijder.phps]verwijder.php[/url] ::

<?php

include('config.php');

include('header.php');

if(!empty($_GET['id']) && is_numeric($_GET['id'])) {

	$sql_a = mysql_query("SELECT COUNT(*) FROM memo WHERE id = '".$_GET['id']."'");

	if(mysql_error()) {

		echo mysql_error();

	} else {

		if(mysql_result($sql_a, 0) == 1) {

			mysql_query("DELETE FROM memo WHERE id = '".$_GET['id']."'");

			if(mysql_affected_rows()) {

				if(mysql_error()) {

					echo mysql_error();

				} else {

					echo '<h2>Verwijdert</h2>'."\n";
					echo '<p>De memo is verwijdert. Klik <a href="index.php">hier</a> om terug te gaan.</p>'."\n";

				}

			} else {

				echo '<h2>Fout</h2>'."\n";
				echo '<p>Het is niet gelukt om de memo te verwijderen. Klik <a href="verwijder.php?id='.$_GET['id'].'">hier</a> om het nog een keer te proberen of klik <a href="index.php">hier</a> om terug te gaan.</p>'."\n";

			}

		} else {

			echo '<h2>Fout</h2>'."\n";
			echo '<p>Sorry maar deze memo bestaat niet. Klik <a href="index.php">hier</a> om terug te gaan.</p>'."\n";

		}

	}

} else {

	echo '<h2>Fout</h2>'."\n";
	echo '<p>Er is geen id meegegeven. Klik <a href="index.php">hier</a> om terug te gaan.</p>'."\n";

}

include('footer.php');

?>