School Map:
Home / Enroll
$ Student Records; Class
$ News @ LIVE
Tech Radio * Support/FAQ
| Store | FORUMS
Class / Forums / php101 ![]() |
Week #10 ADVANCED To-Do Assignment, post here |
(#19 2003-08-07 16:57:50) Post Reply |
|
TDavid
|
Week #10 ADVANCED TO-DO ASSIGNMENT: Write a script to be able to add and delete sorted email addresses and names to a file and with the same script how to retrieve all the information and print to browser the name and email address in a table to the browser.
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!
|
(#267 2003-09-22 08:17:13) Post Reply |
|
Shrek
|
My Week 10 Advanced Assignment
http://members.lycos.co.uk/jef...an/class10a.php
|
(#370 2003-11-06 06:06:51) Post Reply |
|
Dest
|
here is my assignment. I will not give you admin password because i want to see who will add himself :)
url - http://tts.lt/~sir/scripts/week10adv.php |
(#402 2003-11-23 17:18:51) Post Reply |
|
Quicksaver
|
here it is
working url |
(#764 2005-01-20 14:50:03) Post Reply |
|
lestat
|
Took me a while but finally got it after looking for lots of help in the irc chat. I'm now trying to make a checkbox version.
Working URL: http://tdurl.com/bs |
(#844 2005-07-03 05:31:39) Post Reply |
|
vegyta2004
|
MY code:
<form method=POST action="<?$PHP_SELF ?>"> Username: <input type="text" name="user" size=10><br> Password: <input type="password" name="pwd" size=10><br> <input type="hidden"name="action"value="add"> <input type="submit" value="add user"><br> </form> <? $file_directory ="D:\PROGRAME INSTALATE-FUNCTIONALE\wamp\www\proiecte\assignments\week10\basic\pass.txt"; $error = 'Sorry, I could not open this file! Check that the permissions are set properly for this file and that you used the correct absolute path to the file.'; $file_contents = file("$file_directory"); sort($file_contents); $sizeof = count($file_contents); if(($_POST["action"] != "delete")||($_POST["action"] != "add")) { ?> <form method="POST"action="<?$PHP_SELF?>"> <input type="hidden" name="action"value="delete"> <select name="todelete"> <? for($i=0; $i < $sizeof; $i++) {$user = explode(":", $file_contents[$i]); echo"<option value=\"$file_contents[$i]\">$user[0]</option>";} ?> </select> <br> <input type="submit" value="delete user"><br> </form> <? // start action routine for actual deletion or additon of new members } // start action routine for actual deletion or additon of new members if ($_POST["action"]=="add") { if($filehandle = fopen("$file_directory", "a")) { $encrypted_pass = crypt($_POST["pwd"]); fputs($filehandle,$_POST["user"]); fputs($filehandle,":"); fputs($filehandle,$_POST["pwd"]); fputs($filehandle,"\r\n"); fclose($filehandle); echo"Successfully added",$_POST["user"],"to the file";} else {echo($error);} } if ($_POST["action"]=="delete") { if($filehandle = fopen("$file_directory", "w")) { for($i=0; $i<$sizeof; $i++) { if($file_contents[$i]==$_POST["todelete"]) {$flag = 1;} else {fputs($filehandle,$file_contents[$i]);} } //close for fclose($filehandle); if($flag) {echo"Successfully deleted",$_POST["todelete"],"from the file";} else {echo"I didn't find", $_POST["todelete"],"to delete from file";} } else {echo"$error";} } ?> It gives me the error: I didn't find the user to delete. Please help.I tested it on a local server called wamp5. |
(#914 2005-12-30 13:15:53) Post Reply |
|
Gixboy
|
Alright guys, this, like a couple of my other assignments, is not exactly what the assignment asked for. I like taking the CONTENT of the lesson and applying it to something useful that we can all use. This time, I took the .htpasswd file and made it into a feedback form. It's much more dynamic than the assignment, and it puts into use EVERYTHING we've learned, including mail() functions, date() functions, rand() functions, cookies, regular functions, etc. It also has a new thing or two that you'll find extremely useful, which includes creating your own function and replacing thing. I don't know if people having trouble with this assignment will find my feedback script necessarilly useful, but you should still read it if you want to get some ideas.
The script is really broken down into three parts. On one page is the mod login which sets a cookie for the ENTIRE domain and expires when the window is closed. This way, you won't have to create a mod login on every page every time you need a moderator. I decided that this would be much more useful for that reason, plus it saves diskspace. The next part is the feedback form. This is where you put the information you want to submit, and then submit it. The email address field is completely optional, but as you'll see on the final page, if you want to put an email address, you must put a real "looking" one. Also, sadly, because we're using .htpasswd files, you cannot use a colon in the textarea for anything. Emoticons, digital time, etc, are out of the question. Finally, the juice. Because of the use of spaces, it's impossible to delete anything post with spaces because string names cannot include them. I don't know if that makes any sense, but the point is that we must give the "title" of each post a specific and unique number so that it can be deleted later on. That's what the rand function is for. Also, if the user hit enter to make new lines in the textarea, it will mess up your whole table unless you replace the carriage returns with an html break. I think the rest of the thing is self explanatory, but if anyone ever has any questions on any of this, I'm always open for asking. My AIM is tnredsoxfan07, and when I'm on, I'll try to help you with whatever you need. The working url is at <a href="http://www.gixboy.com/">Gixboy.com</a>. I'd give you the address of the actual feedback form, but since it's in three parts, i'll just give you the domain. The feedback form can easilly be found though, it's the second option in the menu. The mod login can be found on the homepage right below the construction image. |
(#982 2006-03-24 02:57:59) Post Reply |
|
Russell
|
heres my lesson 10 advanced to-do assignment. once i got the basic assignment done this one wasnt too hard. working url is here
http://www.bigtitsfinder.com/t...ng/lesson10.php
i added a few things just playing around with it and pounding it into my brain. |
|
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