Jump to content
php.lv forumi

message from user


tiy

Recommended Posts

lietotajs ieraksta viesu gramata kadu zinu caur <textarea>, kuru es ierakstu txt faila

$path="guest.txt";

$name = $_POST['name'];

$msg = $_POST['msg'];

$record=$name."+++".$msg."+++"."\n";

$fp=fopen($path,"a+");

$fw=fwrite($fp,$record);

fclose($fp);

 

, ka man ierakstit $msg ,lai paliktu usera enters, tani vieta ,kur vish to ierakstija teksta, jo failu nolasu ar f-ju file ($path), ierakstu sho masiva un tad ar explode, bet tik lidz ir usera enteri sakas gluki, txt faila vini ir ,bet nav ar sho zimi \n, tad ka man izvadit visu msg ar enteriem un bez erorriem.

Link to comment
Share on other sites

$msg = nl2br($_POST['msg']);

 

 

es jau ta meginaju fila vinsh ieraksta ta piem:

 

vards||message||\n

vards||message

 

dasfsdf

asdff

||\n

 

un ja ar f-ju $mas=file("fails.txt") ; echo count($mas) mas bus 5, bet vajadzetu but 2, ps vinsh saliek tos <br />

Edited by tiy
Link to comment
Share on other sites

×
×
  • Create New...