School Map:
Home / Enroll
$ Student Records; Class
$ News @ LIVE
Tech Radio * Support/FAQ
| Store | FORUMS
Class / Forums / php101 ![]() |
Week #11 Basic To-Do Assignment, post here |
(#20 2003-08-07 17:03:38) Post Reply |
|
TDavid
|
Week #11 Basic TO-DO ASSIGNMENT: Write a script to search through the contents of a file CASE iNsensiTiveLy, match all entries and change from the information submitted on a form and print the entire contents of the file to the browser. All should be self enclosed in one script with find and replace text boxes and use filelocking.
Post this assignment here so that we can offer comment/critique for you, but also post a URL to the working copy of the script and the complete source code of the script in your post. scriptname.php <-- script name Good luck to you!
|
(#404 2003-11-25 15:22:20) Post Reply |
|
Quicksaver
|
used last week's email script for this one
working url |
(#789 2005-03-21 11:24:17) Post Reply |
|
lestat
|
These are getting tougher as we go! I'm srarting to have difficulty with order. Getting things to print out where I want etc.
This code looks a bit sloppy due to all the html formatting Iv'e done to make it look the way I want. I gotta think that includes may change that :) (Next time I will make an unformatted code to post, so others looking at this can use it for a reference) Ok, heres my code:
Working URL: http://tdurl.com/db |
(#847 2005-07-30 14:53:51) Post Reply |
|
vegyta2004
|
MY ASSIGNMENT:
<form name="catutare"method="POST"action="<?php $PHP_SELF?>"> Cauta:<input type="text"name="find"><br> <input type="submit"value="Search"><br> </form> <form name="adaugare"method="POST"action="<?php $PHP_SELF?>"> Adauga:<input type="text"name="add"><br> <input type="submit"value="add"> </form> <? //citirea din fisier--------Inceput $path="/home/vegyta/public_html/proiecte/basic.txt"; $file=fopen($path,"r"); flock($file,LOCK_SH); while(!feof($file)) {$info[]=fgets($file);} ?> <p align="center"> <font size=4 color=Blue>Date existente:</font> <table border=1> <td> <? foreach($info as $key=>$value) {echo"$value","<br>";} ?></td> </table> </p> <? //citirea din fisier--------Sfarsit flock($file,LOCK_UN);fclose($file); //adaugarea In fisier-----> Inceput if($_POST["add"]){ $file4=fopen($path,"a"); flock($file4,LOCK_EX); if((fwrite($file4,$_POST["add"]))&&(fwrite($file4,"\r\n"))) {echo"element adaugat";} else{echo"eroare la adaugare";} flock($file4,LOCK_UN); fclose($file4);} //adaugarea In fisier-----> Sfarsit //Search------->Inceput if(($_POST["find"]=="")||($_POST["find"]==" ")) {} else{$fisier=file($path); ?> <div align="center"> <font size=4 color=Blue>Rezultatele Cautarii:</font> <table border=1> <? $b=0; foreach($fisier as $key=>$value) {if(eregi($_POST["find"],$value)){ echo"<tr>"; echo"<td>"; echo"$value","<br>";$a=1;$b=$b+1; echo"</td>"; }} ?></table></div> <? if($a==1) {} else{echo"elementul cautat nu exista";} } if($b>0) { echo"<div align=\"center\">"; ?> <form metod="GET" action="<?$PHP_SELF?>"> <input type="submit" value="Modification"> <input type="hidden" name="Modification" value="action1"> </form> <? echo"<form metod=\"POST\" action=\"$PHP_SELF\">"; echo"<input type=\"submit\"value=\"Delete\">"; echo"<input type=\"hidden\" name=\"Delete\"value=\"action2\">"; echo"</form>"; echo"</div>";} //MODIFICAREA UNEI VALORI if($_GET["Modification"]){ $fisier=file($path); echo"<form metod=\"GET\"action=\"$PHP_SELF\">"; foreach($fisier as $key=>$value){ echo"$value"; echo"<input type=\"checkbox\" name=\"ver\" value=\"$value\">","<br>" ;} echo"<input type=\"text\"name=\"New\">"; echo"<input type=\"submit\"value=\"Update Value\">"; echo"</form>"; } if($_GET["New"]) { $verificare=$_GET["ver"]; echo"$verificare"; $fisier=file($path); $fisier2=fopen($path,"w"); flock($fisier2,LOCK_EX); foreach($fisier as $key=>$value) { if(eregi($verificare,$value)){echo"verificat";} else{ fwrite($fisier2,$value);} } if((fwrite($fisier2,$_GET["New"])) and (fwrite($fisier2,"\r\n"))) {echo"Valoarea a fost modificata cu succes";} else{echo"eroare la adaugarea noii valori";} flock($fisier2,LOCK_UN); fclose($fisier2); } // stergerea if($_GET["Delete"]){ $fisier=file($path); echo"<form metod=\"GET\"action=\"$PHP_SELF\">"; foreach($fisier as $key=>$value){ echo"$value"; echo"<input type=\"checkbox\" name=\"del\" value=\"$value\">","<br>" ;} echo"<input type=\"submit\"value=\"Delete Value\">"; echo"</form>"; } if($_GET["del"]) { $verificare_del=$_GET["del"]; echo"$verificare_del"; $fisier=file($path); $fisier2=fopen($path,"w"); flock($fisier2,LOCK_EX); foreach($fisier as $key=>$value) { if(eregi($verificare_del,$value)){echo"Valoare Stearsa";} else{ fwrite($fisier2,$value);} } flock($fisier2,LOCK_UN); fclose($fisier2); } ?> |
(#848 2005-07-30 14:54:45) Post Reply |
|
vegyta2004
|
OO,my working url http://www.vegyta.ropage.com/p...eek11_basic.php |
(#926 2006-01-04 19:22:22) Post Reply |
|
Dylan
|
I sure had trouble with an extra black space sneaking into my variables -- thanks go to Lestat for showing me how to use trim(); to clear that issue up!
Working link: http://www.algore.org/~admin/m...le_advanced.php And the code follows (note that the code is visible the link above I'm testing out the other new function Lestat showed me highlight_file(); |
|
View Previous Thread Print This Page |
School Map:
Home / Enroll
$ Student Records; Class
$ News @ LIVE
Tech Radio * Support/FAQ
| Store
Advertising
| Link To Us | Privacy
Copyright 2000-2002 Script School Productions / KMR
Enterprises
No part of this website may be reproduced, copied and/or distributed
in any medium
without express written permission