خب بزارید واضح تر بگم ما مثلا همیچن صفحه html رو داریم
کد HTML:
<html> <head> <link rel="stylesheet" type="text/css" href="style.css"> <!--<script src="jquery.min.js" type="text/javascript"></script>
<script> $('#run').keypress(function (e) { if (e.which == 13) { $('form#login').submit(); return false; } });
</script>--> </head> <body> <script> document.body.addEventListener('keydown', function (e) { var keyCode = e.keyCode; if(keyCode == 13) { document.getElementById('submit').click(); } }); </script> <form id="login" action="#" method="POST"> <textarea autocorrect="off" autocapitalize="off" spellcheck="false" tabindex="0" class="textarea" Autocomplete="off" type="text" name="bv" id="code"><?php echo $tell."\n";?></textarea> <input type="submit" class="btn-action" id="submit"> </form>
<script> document.getElementById('code').click(); </script> </body></html>
این ها به همون صفحه ارسال میشه حالا کد های php اون
<?php
$tell = null;
if(isset($_POST['bv'])){ $gap = $_POST['bv']; echo "gqp=".$gap."<br>"; $set =explode(' ',$gap); $char = str_word_count($gap); if((isset($_COOKIE['gapCOCE']))){ $ek = $_COOKIE['gapCOCE']; echo "ek=".$ek."<br>"; $set_ek =explode(" ",$ek); $char = str_word_count($ek); echo "set=".$set[0]."<br>"."set_ek=".$set_ek[0].'<br><br>'; echo "SET[0] : ".$set_ek[0]."<br><br>"; while($set_ek[0] == $set[0]){ array_splice($set_ek, 0, 1); array_splice($set, 0, 1); //unset($set_ek[0]); //unset($set[0]); if($set_ek[0] == null){ break; } echo "set=".$set[0]."<br>"."set_ek=".$set_ek[0].'<br>'; } } else{ echo"0225"; } echo "<br>set end :".$set[0].'<br>'; switch($set[0]){ case 'hello': case 'Hello': case 'HELLO': $tell = "\nhello:)"; break; case 'how': case 'How': case 'HOW': if($char >= 2){ switch($set[1]){ case 'are': case 'Are': case 'ARE': if($char >= 3){ switch($set[1]){ case 'you': case 'You': case 'YOU': $tell = "thanks, I'm fine"; break; } }else{ $tell = "Well now you said".$set[0].$set[1]; } } }else{ $tell = "Sorry I do not understand your question! :("; } break; default: $tell = "I don't understand"; break; } $tell = $gap.$tell;
setcookie("gapCOCE", $tell , time() + (20*60));
}
?>
همه کد های echo برای نمایش مقدار پیشرفت هستش خب مثلا من عبارت hello رو وارد میکنم جواب هم میگرم اندفه که اطلاعات ارسال مبشن اون hello هم ارسال میشه ما باید اون hello رو بر اساس اون کوکی که داریم تشخیص بدیم و حذف کنیم