Find file
Fetching contributors…
Cannot retrieve contributors at this time
47 lines (47 sloc) 1.48 KB
Sharing validation client and server side
Copyright (c)2010 Christian Heilmann
Code licensed under the BSD License:
function rendererror($name){
global $error;
echo '<span class="error">'.$error[$name].'</span>';
} else {
echo '<span class="required">*</span>';
<?php if ($req == ''){ ?>
<form action="index.php" method="post" id="mainform">
<?php } ?>
<?php if(sizeof($error)>0){?>
<div class="error">The form cannot be sent yet as there were some errors.
Please fix them and try again.</div>
<?php }?>
<label for="name">Name <?php rendererror('name');?></label>
<input type="text" name="name" value="<?php echo $name;?>" id="name">
<label for="email">Email <?php rendererror('email');?></label>
<input type="text" name="email" value="<?php echo $email;?>"
<label for="homepage">Homepage</label>
<input type="text" name="homepage" value="<?php echo $homepage;?>"
<label for="message">Message <?php rendererror('message');?></label>
<textarea name="message" id="message" value="<?php echo $message;?>"><?php echo $message;?></textarea>
<div class="bar"><input type="submit" name="done" value="Make it so!"></div>
<?php if ($req == ''){ ?>
<?php } ?>