Puika1 Posted June 1, 2009 Report Share Posted June 1, 2009 (edited) sveiki variet man iedot tādu scriptiņū piemēram dienas teksts ierakstot lodziņā tekstu tas saglabājās txt failā un redzams kautkur weblapā un kad rakstot nākošo pārakstās pāri tam iepriekšējam help :) Edited June 1, 2009 by Puika1 Quote Link to comment Share on other sites More sharing options...
bubu Posted June 1, 2009 Report Share Posted June 1, 2009 Formu lapā, kur ievadīt to tekstu, htmlā pieraksta ar <textarea> tagu. Tekstu failā ieraksti ar file_put_contents funkciju. Tekstu no faila nolasi ar file_get_contents funkciju un izvadi to lapā ar echo funkciju. Quote Link to comment Share on other sites More sharing options...
Puika1 Posted June 1, 2009 Author Report Share Posted June 1, 2009 (edited) mazliet precīzāk avrētu? es neēsmu no tiem gudrākajiem bet man laikam patīk tava ideja :) es sapratu tikai textarea Edited June 1, 2009 by Puika1 Quote Link to comment Share on other sites More sharing options...
bubu Posted June 1, 2009 Report Share Posted June 1, 2009 Ko tieši tu nesaprati no pārējā? Quote Link to comment Share on other sites More sharing options...
Puika1 Posted June 1, 2009 Author Report Share Posted June 1, 2009 es megināju šādi pieteikums.php <form name="forma" method="POST" action="post.php"> <input type="text" name="teksts" size="25"> <input type="submit" value="Nosūtīt" name="poga"> </form> post.php <?php if(isset($_POST['teksts'])){$teksts=$_POST['teksts'];} else {$vards="nekas nav atsutits";} $fails = fopen("fails.txt", "w"); fwrite($fails,$teksts); fclose($fails); ?> bet problema sada ka teksts saglabajas txt failā,bet iekš post.php viņs neuzrādās Quote Link to comment Share on other sites More sharing options...
superKrona Posted June 1, 2009 Report Share Posted June 1, 2009 un kur viņam iekš tā post.php būtu jāuzrādās? Quote Link to comment Share on other sites More sharing options...
Puika1 Posted June 1, 2009 Author Report Share Posted June 1, 2009 vot to es nezinu :) ka var lai raditu tekstu aks atrodas txt dokumenta? Quote Link to comment Share on other sites More sharing options...
superKrona Posted June 1, 2009 Report Share Posted June 1, 2009 include 'fails.txt'; Quote Link to comment Share on other sites More sharing options...
Puika1 Posted June 1, 2009 Author Report Share Posted June 1, 2009 Opā esmu idiots :D uzreiz nevarēju iedomāties be tikuntā paldies :) Quote Link to comment Share on other sites More sharing options...
bubu Posted June 1, 2009 Report Share Posted June 1, 2009 Kā tu tekstu izvadi no php uz html? Ar echo, ne? Un to, kā nolasīt faila saturu es jau augstāk pieminēju: echo file_get_contents("fails.txt"); Ierakstīt failā es ar pateicu kā var īsāk, nevajag fopen/fwrite/fclose: file_put_contents("fails.txt", $teksts); Quote Link to comment Share on other sites More sharing options...
Puika1 Posted June 1, 2009 Author Report Share Posted June 1, 2009 jus enzinat ka saja scripta <form name="forma" method="POST" action="post.php"><input type="text" name="teksts" size="25"> <input type="submit" value="Nosūtīt" name="poga"> </form> tas kas aukstak minets ierobezot burtu skaitu piemeram uz kadiem 50?lai nevaretu vairak pievienot? Quote Link to comment Share on other sites More sharing options...
bubu Posted June 1, 2009 Report Share Posted June 1, 2009 To dari php pusē pie teksta rakstīšans failā. Funkcija, kas apgriež stringa garumu saucas substr. Quote Link to comment Share on other sites More sharing options...
Puika1 Posted June 1, 2009 Author Report Share Posted June 1, 2009 ok viss ir ok atjkal paldies Quote Link to comment Share on other sites More sharing options...
Puika1 Posted June 1, 2009 Author Report Share Posted June 1, 2009 doh pamaniju velvienu problēmu rekus scripts <form name="forma" method="POST" action="post.php" <p> <textarea name="teksts" cols="40" rows="10"></textarea> </textarea> </form> </p> <p><input type="submit" value="Pievienot" name="poga" /> </p> <?php if(isset($_POST['teksts'])){$teksts=$_POST['teksts'];} else {$vards="nekas nav atsutits";} $fails = fopen("fails.txt", "w"); fwrite($fails,$teksts); fclose($fails); include("up.php") ?> kad esmu ierakstijis tekstu viss ir ok bet pec kāda ,laiciņa teksts pazūd no txt dokumenta Quote Link to comment Share on other sites More sharing options...
bubu Posted June 1, 2009 Report Share Posted June 1, 2009 Ja tu to otro koda gabalu izsauc ne no postēšanas formas, tad $teksts mainīgais būs nedefinēts. Ja tev ir atslēgtas kļūdu ķeršanas un parādīšanas, tad failā ierakstīsies tukšums. Ieliec pašā pašā skripta sākumā sekojošas rindas: error_reporting(E_ALL); ini_set("display_errors", true); Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.