HTML and CSS Reference
In-Depth Information
<title>
Registration Form
</title>
<style type=”text/css”>
label.error {
color: red;
}
</style>
</head>
<body>
<h1>
Registration Form
</h1>
<p>
Please fill out the form below to register for our site. Fields
with bold labels are required.
</p>
<?php if (!empty($errors)) { ?>
<ul>
<?php foreach (array_values($errors) as $error) { ?>
<li>
<?= $error ?>
</li>
<?php } ?>
</ul>
<?php } ?>
<form method=”post” action=”<?= $_SERVER['PHP_SELF'] ?>”>
<p>
<?php if (array_key_exists('name', $errors)) { ?>
<label for=”name” class=”error”><b>
Name:
</b></label>
<?php } else { ?>
<label for=”name”><b>
Name:
</b></label>
<?php } ?>
<br />
<input name=”name” value=”<?= strip_tags($_POST['name']) ?>” /></p>
<p>
<?php if (array_key_exists('age', $errors)) { ?>
<label for=”age” class=”error”><b>
Age:
</b></label>
<?php } else { ?>
<label for=”age”><b>
Age:
</b></label>
<?php } ?>
<br />
<input name=”age” value=”<?= strip_tags($_POST['age']) ?>”/></p>
<p>
<?php if (array_key_exists('toys', $errors)) { ?>
<label class=”error”><b>
Toys:
</b></label>
<?php } else { ?>
<label><b>
Toys:
</b></label>
<?php } ?>
<br />
<?php foreach ($toys as $key => $value) { ?>
<label><input type=”checkbox” name=”toys[]”
<?php if (array_key_exists('toys', $_POST) && in_array($key,
