ورود

View Full Version : کار نکردن کپچا کد



nokhodi
یک شنبه 16 شهریور 1393, 13:54 عصر
سلام
دستورات صفحه ایجاد کپچا :


<?php


session_start();


$string = '';


for ($i = 0; $i < 4; $i++) {
// this numbers refer to numbers of the ascii table (lower case)
$string .= chr(rand(48, 57));
}


$_SESSION['rand_code'] = $string;


$dir = 'fonts/';


$image = imagecreatetruecolor(90, 35);
$black = imagecolorallocate($image, 0, 0, 0);
$color = imagecolorallocate($image, 100, 100, 90);
$white = imagecolorallocate($image, 255, 255, 255);


imagefilledrectangle($image,0,0,399,99,$white);
imagettftext ($image, 16, 0, 5, 30, $color, $dir."acmesai.ttf", $_SESSION['rand_code']);


header("Content-type: image/png");
imagepng($image);


?>


برای ارسال و شرط بررسی کپچا :



<?php if(isset($_POST['frm_submit'])) {

if(!empty($_POST['name']) && !empty($_POST['email']) && !empty($_POST['content']) && !empty($_POST['code']) && !empty($_POST['subject'])) {

if($_POST['code'] == $_SESSION['rand_code']) {

$name=htmlspecialchars($_POST['name']);
$email=htmlspecialchars($_POST['email']);
$subject=htmlspecialchars($_POST['subject']);
$content=htmlspecialchars($_POST['content']);

if(sendEmail($name,$email,$subject,$content)){

?>
<p><?php echo " درخواست شما با موفقیت ثبت شد.در صورت نیاز با شما تماس گرفته می شود";?></p>
<?php

}
}

else {

?>
<p><?php echo " کد امنیتی را اشتباه وارد کرده اید! دوباره امتحان کنید";?></p>
<?php


}
}


else {

?>
<p><?php echo "لطفا تمامی فیلد ها را تکمیل نمایید.";?></p>
<?php
}

}

function sendEmail($name,$email,$subject,$content){
ob_start();
include 'template.php';
$html=ob_get_contents();
ob_end_clean();
$html= str_replace('{name}',$name, $html);
$html= str_replace('{email}',$email, $html);
$html= str_replace('{subject}',$subject, $html);
$html= str_replace('{content}',$content,$html);
$headers = 'From: no-reply@domain.com'. "\r\n" .
'MIME-Version: 1.0' . "\r\n" .
'Content-type: text/html; charset=utf-8' . "\r\n" .
'X-Mailer: PHP/' . phpversion();

return mail("Admin<xxxxx@gmail.com>","درخواست جدید در وب سایت", $html, $headers);
}
?>


شرط بررسی کپچا میگه اشتباه وارد میکنی در صورتی که دقیقا اعداد رو وارد میکنم