السلام عليكــم ورحمـة الله وبركاتــه ،،
لدي كود التحقق الأمني و يعمل بدون مشاكل مع الفورم
كيف اضيف نفس الكود لفورم اخر علما ان الملف اسمه كابتشا و يعمل مع ملف اسمه فورم جيدا و لكني اريد اضافته على ملف اسمه كومنتس
و هذه هي اكودا الملفات الثلاثه
ملف كابتشا
<?php
session_start();
$width = 88;
$height = 30;
$im = imagecreate($width, $height);
$bg = imagecolorallocate($im, 0, 0, 0);
// generate random string
$len = 5;
$chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
$string = '';
for ($i = 0; $i < $len; $i++) {
$pos = rand(0, strlen($chars)-1);
$string .= $chars{$pos};
}
$_SESSION['captcha_code'] = md5($string);
// grid
$grid_color = imagecolorallocate($im, 175, 0, 0);
$number_to_loop = ceil($width / 20);
for($i = 0; $i < $number_to_loop; $i++) {
$x = ($i + 1) * 20;
imageline($im, $x, 0, $x, $height, $grid_color);
}
$number_to_loop = ceil($height / 10);
for($i = 0; $i < $number_to_loop; $i++) {
$y = ($i + 1) * 10;
imageline($im, 0, $y, $width, $y, $grid_color);
}
// random lines
$line_color = imagecolorallocate($im, 130, 0, 0);
for($i = 0; $i < 30; $i++) {
$rand_x_1 = rand(0, $width - 1);
$rand_x_2 = rand(0, $width - 1);
$rand_y_1 = rand(0, $height - 1);
$rand_y_2 = rand(0, $height - 1);
imageline($im, $rand_x_1, $rand_y_1, $rand_x_2, $rand_y_2, $line_color);
}
// write the text
$text_color = imagecolorallocate($im, 255, 0, 0);
$rand_x = rand(0, $width - 50);
$rand_y = rand(0, $height - 15);
imagestring($im, 10, $rand_x, $rand_y, $string, $text_color);
header ("Content-type: image/png");
imagepng($im);
?>ملف الفورم
<?php
session_start();
if(isset($_POST['submit'])) {
if(isset($_POST['captcha_code']) && isset($_SESSION['captcha_code'])) {
if(md5($_POST['captcha_code']) == $_SESSION['captcha_code']) {
echo 'Result : CAPTCHA code correct.<br />';
}else{
echo 'Result : CAPTCHA code incorrect.<br />';
}
}else{
if(!isset($_POST['captcha_code'])) {
echo 'Result: No security code was entered.<br />';
}
if(!isset($_SESSION['captcha_code'])) {
echo 'Result: No CAPTCHA was viewed.<br />';
}
}
}
?>
<form method="post" action="comments_send.php">
<img src="captcha.php" />
<br />
Enter the above text EXACTALY as it appears. Note: It is case sensitive<br />
<input type="text" name="captcha_code" />
<br />
<input type="submit" name="submit" value="Submit" />
</form>ملف الكومنتس
<?php if (!defined("_COMMON_")) {echo "stop";exit;}?>
<html dir="ltr">
<head>
<meta http-equiv="Content-Language" content="ar-sy">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1256">
<title>Contact The Administration</title>
<link rel="STYLESHEET" type="text/css" href="<?php echo $current_design;?>purple_style.css">
<BODY oncontextmenu="return false" onselectstart="return false"
ondragstart="return false">
</head>
<script type="text/javascript">
function validate_required(field,alerttxt)
{
with (field)
{
if (value==null||value=="")
{
alert(alerttxt);return false;
}
else
{
return true;
}
}
}
function validate_form(thisform)
{
with (thisform)
{
if (validate_required(name,"Name Field Must Be Filled With Your Nick")==false)
{name.focus();return false;}
if (validate_required(email,"E-mail Field Must Be Filled With Valid E-mail Address")==false)
{email.focus();return false;}
if (validate_required(comment,"Message Body ( Text ) Must Be Filled And Can NOT Be Left Empty")==false)
{comment.focus();return false;}
}
}
</script>
<body background="<?php echo $current_design;?>images/who.gif">
<form action="comments_send.php" onsubmit="return validate_form(this)" method="post">
<?php echo $w_feed_headline; ?><br><br>
<center><img src="<?php echo $current_design;?>images/who_line.gif" width="350" height="9" border="0" alt="">
</td></tr><br><br>
<form method="post" action="comments_send.php">
<table border=1 bordercolor= 000080 cellpadding=3 cellspacing=1>
<tr><td><?php echo $w_feed_name;?></td><td>
<input type="text" name="name" onclick="this.style.backgroundColor='red';" onblur="this.style.backgroundColor='';" autocomplete="off" onfocus="this.value=''" class="input" size="20" maxlength="15"></td></tr>
<tr><td><b>E-Mail</b> </td><td><input type="text" name="email" onclick="this.style.backgroundColor='red';" onblur="this.style.backgroundColor='';" autocomplete="off" onfocus="this.value=''" class="input" size="20" maxlength="30"></td></tr>
<tr><td valign="top"><?php echo $w_feed_message;?></td><td>
<textarea name="comment" rows="10" cols="80" class="input"></textarea></td></tr>
<tr><td colspan="2">
<center><input type="submit" value="<?php echo $w_send;?>" class="input">
</table>
<br>
<b>Note : provide a valid E-Mail Address to receive our reply</b>
</form>
</body>
</html>علما ان الكابتشا هي حساسة لحالة الحرف فكيف اجعلها غير تتجاهل حالة الحرف و شكرا سلفا
