Speed Posted March 6, 2007 Report Share Posted March 6, 2007 (edited) es uztakstiju scriptu 1.php <html> <head> </head> <body> <form method="POST" action="2.php"> <input type="text" name="txt"> <input type="submit" name="submit" value="ok"> <input type="reset" name="reset" value="izdzest" </form> </body> </html> 2.php <?php $url = "fails.txt"; $text="$txt"; $fh = fopen($url, "a"); fwrite($fh,$text); fclose($fh); ?> vis strada bet man vaig lai $txt ierakstitos jauna rinda ! kaa to var izdarit ? Edited March 6, 2007 by Speed Link to comment Share on other sites More sharing options...
andrisp Posted March 6, 2007 Report Share Posted March 6, 2007 Pirms ierakstīšanas ielasi tā faila saturu mainīgajā (file_get_contents, file, fopen+fread). Un tad pie ierakstīšanas: fwrite($fh, $vecais_saturs."\n\r".$pievienojamaa_rinda); Btw, $text = "$txt"; <- no tām pēdiņām nav nekāda jēga. Link to comment Share on other sites More sharing options...
Val Posted March 6, 2007 Report Share Posted March 6, 2007 Sauciens no zāles: Tev register_globals ir on vai off? Link to comment Share on other sites More sharing options...
Speed Posted March 6, 2007 Author Report Share Posted March 6, 2007 on man fopen() vieta izmanot file() ? Link to comment Share on other sites More sharing options...
Stopp Posted March 6, 2007 Report Share Posted March 6, 2007 Gribētu redzēt, kā tu fopen aizstāsi ar file. RTFM. file vai file_get_contents būs jāliek pirms rakstīšanas failā. Link to comment Share on other sites More sharing options...
andrisp Posted March 6, 2007 Report Share Posted March 6, 2007 Speed, silti iesaku register_globals Off. Un sākt izmantot $_GET un $_POST masīvus. Link to comment Share on other sites More sharing options...
blackhalt Posted March 7, 2007 Report Share Posted March 7, 2007 Vispār jau vajag darīt tā, ka tekstu ieraksta ar jaunrindi: $fp=fopen($fails,'a'); fwrite($fp,"$txt\n");// vai piekabināt klāt $txt."\n" fclose($fp); nu, ja tā nevar, tad: $fp=fopen($fails,'a'); fwrite($fp,"\n".$txt); fclose($fp); Link to comment Share on other sites More sharing options...
v3rb0 Posted March 7, 2007 Report Share Posted March 7, 2007 un pārbaudi, vai textā jau nav jauna rinda, vai arī serializē to textu vai kaut kā tā :) Link to comment Share on other sites More sharing options...
Recommended Posts