Jump to content
php.lv forumi

fwrite


Speed

Recommended Posts

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 by Speed
Link to comment
Share on other sites

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

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

×
×
  • Create New...