I need somting like this Click Here , but a want to type letters in separate <input> one <input> one letter.
My script find just words with 4 letters if i type 'g','o','l','d' he find me just 'gold' but don't find 'old' and if have the same letters.
I don't know how to write correctly if function.
Maybe I'm started a good, maybe I'm not. Pls tell me where is my fault and how i can fix that.
HTML CODE:
<form action="" method="post">
<input id="box" name="letter1" type="text" maxlength="1" >
<input id="box" name="letter2" type="text" maxlength="1" >
<input id="box" name="letter3" type="text" maxlength="1" >
<input id="box" name="letter4" type="text" maxlength="1" >
<input type="submit">
</form>
PHP CODE:
$letter1 = $_POST['letter1']; /* 1st letter */
$letter2 = $_POST['letter2']; /* 2nd letter */
$letter3 = $_POST['letter3']; /* 3rd letter */
$letter4 = $_POST['letter4']; /* 4th letter */
$array = array('old','gold','put','road'); /* array of words */
for ($x=0; $x<sizeof($array); $x++){
$pos1 = strpos($array[$x], $letter1); /* check 1st letter in all words */
$pos2 = strpos($array[$x], $letter2); /* check 2nd letter in all words */
$pos3 = strpos($array[$x], $letter3); /* check 3rd letter in all words */
$pos4 = strpos($array[$x], $letter4); /* check 4th letter in all words */
if ($pos1!== false and $pos2!== false and $pos3!== false and $pos4!== false){
echo $array[$x]."<BR>";
}
}