Location: PHPKode > scripts > Oziam Captcha > example.php
 * Author: Oziam Web Development
 * Email:  hide@address.com
 * Call captcha code, add this to your form page
<img src="captcha/captcha_class.php" id="docaptcha" onclick="this.src='captcha/captcha_class.php?'+Math.random();" style="cursor:hand" title="Click to refresh code">
 * If you want to change the default font settings like image, font, size, skew, number of characters, colour etc, edit captcha_class.php in captcha folder


print <<<HTML
<title>Oziam Captcha Example</title>


  $msg = '* Mandatory fields';
  $name  = null;
  $email = null;
  $text  = null;

// Check submitted form for errors and proceed with mailing

  if(isset($_POST['act']) && $_POST['act'] == 'send'){
	$error = null;
	$name = strip_tags(trim($_POST['name']));
	$email = trim($_POST['email']);
	$code = trim($_POST['code']);
	$text = strip_tags(trim($_POST['message']));
	$error .= '<font style="line-height:1.5; color:#FF0000">Enter your name.</font><br />';
	if(!preg_match('/^[^@\s]+@([-a-z0-9]+\.)+[a-z]{2,}$/i', $email)) {
	$error .= '<font style="line-height:1.5; color:#FF0000">Enter a valid email address.</font><br />';
	$email = null;
	if($_SESSION['code'] != $code || empty($_SESSION['code'])){
	$error .= '<font style="line-height:1.5; color:#FF0000">Enter correct security code <small>(case sensitive)</small>.</font><br />';
	$error .= '<font style="line-height:1.5; color:#FF0000">Enter a message.</font><br />';
	if($error != null){
	$msg = '<p>Incomplete information, please correct the following;<p>'.$error;
	// put your mail header and mailto command here //
	// lets send the user a thankyou message then clear all the form fields and kill session code.
	$msg = '<p><b>Thank you</b><p>If you require an answer someone will get back to you as soon as possible.<p>';
  $name  = null;
  $email = null;
  $text  = null;

print <<<HTML

<table align="center" style="padding-left:20px" cellpadding="10" border="0" width="100%">
    <td width="100%"><h1>Contact Us</h1><hr>
<p style="margin-top:20px">
<table border="0" cellspacing="0" width="450">
<tr align="left"><td>$msg</td></tr>
<form action="$_SERVER[PHP_SELF]" method="post">
<input type="hidden" name="act" value="send">
<table border="0" style="background:#EEEEEE" cellspacing="5" width="450">
<tr><td height="40">* Name:</td><td>
<input type="text" size="20" name="name" value="$name" maxlength="20"></td></tr>
<tr><td height="40">* Email:</td><td>
<input type="text" size="40" name="email" value="$email" maxlength="40"></td></tr>
<tr><td>&nbsp;</td><td><img src="captcha/captcha_class.php" id="docaptcha" onclick="this.src='captcha/captcha_class.php?'+Math.random();" align="right" style="margin-right:18px; cursor:hand" title="Click to refresh code">Enter security code:<p style="margin-top:5px">
<input type="text" size="18" name="code" maxlength="10"></td></tr>
<tr><td>&nbsp;</td><td><small>&nbsp;NB: Security code is case sensitive, click code to refresh.</small></td></tr>
<tr><td valign="top">* Message:</td><td><textarea name="message" style="width:340; height:100">$text</textarea></td></tr>
<tr><td colspan="2" align="right"><input type="submit" value="Send">&nbsp;&nbsp;&nbsp;</td></tr>

Return current item: Oziam Captcha