Any direction on this would be great. Thanks in advance.
The $codeVal has to be installed somewhere with the else if (md5($code) == $_SESSION[‘image_random_value’]) to facilitate the setting of the error on the entry of an invalid captcha code entry to the input field! This is shown in line 4 of the code below. I have tried all ways of writing the line with the $codeVal included but to no effect. Am I on the correct track?
I have followed the same principle as that used in the email and phone Validate codes but I do not get the result. Thus, having difficulty making progress with this aspect of the captcha validation!
I include the email and phone validation code as they work to requirements with the $emailVal and $phoneVal installed.
Captcha control as follows from the validate.php:
/* Validate captcha entry*/
public function validateCode($codeVal, $codeName) {
if (strlen($codeVal) <= 0) {
$this->setError($codeName, "Enter Validate Code");
} else if(md5($code) == $_SESSION['image_random_value']) {
$this->setError($codeName, "Valid Code Required");
}
}
/* Validate email address */
public function validateEmail($emailVal, $emailName) {
if (strlen($emailVal) <= 0) {
$this->setError($emailName, "Address Required");
} else if (!preg_match('/^[^0-9][a-zA-Z0-9_]+([.][a-zA-Z0-9_]+)*[@][a-zA-Z0-9_]+([.][a-zA-Z0-9_]+)*[.][a-zA-Z]{2,4}$/', $emailVal)) {
$this->setError($emailName, "Valid Address Required");
}
}
/* Validate phone no entry to allow numbers only */
public function validatePhone($phoneVal, $phoneName) {
if (strlen($phoneVal) <= 0) {
$this->setError($phoneName, "Number Required");
} else if (preg_match('/[^0-9]/', $phoneVal)) {
$this->setError($phoneName, "Valid Number Required");
}
}
Captcha panel visible to visitor as follows from the contact.php:
<fieldset>
<legend>Validate Form <span class="errors"><?php echo $codeErr ?></span></legend>
<span class="required">Required</span>
<center>
<img src="randomImage.php" alt="Captcha Image"/>
<input type="text" name="code" class="data"/>
<!--Refresh Validate Code Button Facility-->
<div id="flip"><a href onclick="history.go()" class="link" alt="Refresh Code" /></a></div>
</center>
</fieldset>
and it looks like the visitorView.jpg image attached which shows the random generated image and the data or code input field.