forms - PHP replacing a line from text file -


i have canvas submitting value hidden field in html document.

<form name="hiddenstuff" method="post" onsubmit="return submittodoc()" action=""> <input type="hidden" id="new" value=""> </form> 

and know proper info being stored in because javascript executes fine:

alert(submitinfo); document.getelementbyid('new').value=submitinfo; alert(document.getelementbyid('new').value); document.forms['hiddenstuff'].submit(); 

this alerts same info twice, know info stored in value.

anyways, have following function... not working properly. nothing gets changed in text file.

function submittodoc(){     $content=$_post['new'];     $filenamechallenge="challenge.txt";         $file_handlechallenge=fopen($filenamechallenge,"rw") or die("file won't open. please contact site administrator.");                  $matchfound=false;           while(!feof($file_handlechallenge) && !$matchfound){             $linechallenge=fgets($file_handlechallenge);             $linesplitchallenge=explode("\t",$linechallenge,3);             $linesplitnewchallenge=explode("\t",$content,3);             if ($linesplitnewchallenge[0]==$linesplitchallenge[0] && $linesplitnewchallenge[1]==$linesplitchallenge[1])  {                 $matchfound=true;                 file_put_contents($filenamechallenge, $content);             }             }     fwrite($file_handle,$content);     fclose($file_handle); } 

the string in challenge.txt is, if (the line replacing same, except numbers changed).

mail1   mail2   1   0   0   0   0   0   0   0   0   1   1   1   1   2   2   2   2   0   0   0   0   1   1   1   1   2   2   2   2   0   0   0   0    


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -