School Map:
Home / Enroll
$ Student Records; Class
$ News @ LIVE
Tech Radio * Support/FAQ
| Store | FORUMS
Class / Forums / php101 ![]() |
Week #9 ADVANCED To-Do Assignment, post here |
(#17 2003-08-07 16:54:02) Post Reply |
|
TDavid
|
Week #9 TO-DO ASSIGNMENT: Write a script to enter urls using a form and save the unique urls in a cookie for the current browser session, and then display the urls that are saved using the same script as active hyperlinks opening in a target window. Write an administration script with the ability to modify and delete urls from the set cookies and protect access to this by using a script-based hard-coded password protection area. In the form portion where you modify the existing links be sure to prefill the input form with the existing url so it can more easily be modified.
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!
|
(#260 2003-09-22 02:08:43) Post Reply |
|
Shrek
|
My Week 9 Advanced To Do Assignment
http://members.lycos.co.uk/jef...an/class09a.php |
(#339 2003-10-29 05:13:22) Post Reply |
|
Quicksaver
|
finnaly! thanks to logspirit for helping me with that warning :)
working url |
(#369 2003-11-05 09:32:02) Post Reply |
|
Dest
|
Im going to be third who makes it :) cool :)
i made 2 scripts. enter page (where you enter pass) and main script. login: dest pass: script enter page: http://tts.lt/~sir/scripts/week9adventer.php main script: http://tts.lt/~sir/scripts/week9adv.php main script code: |
(#390 2003-11-19 04:37:07) Post Reply |
|
Quicksaver
|
ok, im changing hosts and thats why ive been a lil delayed with assignement 10
on my new host register_globals are off so i was updating all my scripts to work with that, but this one either needs something more or i just dont get what wrong. the code is basically the same, just added the following $trings to the beggining of each:
the rest is exactly the same. I dunno what im missing, if i enter the admin mode it doesnt show the urls on the cookie! help?! its here |
(#399 2003-11-22 04:00:38) Post Reply |
|
Quicksaver
|
never mind, fixed it (dunno how but fixed it :)) |
(#842 2005-06-23 10:45:37) Post Reply |
|
vegyta2004
|
Week9_advanced.php:
<? $valid_username="vegyta"; $valid_password="seling"; if(($username==$valid_username)and($password==$valid_password)) { header("Location:week9_advanceds.php");} else{echo"Invalid username of password";} ?> <HTML> <BODY> <br><br><br><br> <form method="POST" action="<?PHP_SELF?>"> USERNAME:<input type="text" name="username"><br> PASSWORD:<input type="password"name="password"><br> <input type="submit"value="LOG IN"><br> <input type="reset"value="Reset data"> </BODY> </HTMl> File week9_advanceds: <HTML> <BODY> WELCOME ADMIN VEGYTA!<br> <form method="POST" action="<?PHP_SELF?>"> new url1:<input type="text"name="modified_url_1"><br> new url2:<input type="text"name="modified_url_2"><br> new url 3:<input type="text"name="modified_url_3"><br> DELETE URL:<input type="checkbox" name="deleted_url"value="true"><br> <input type="submit"name="Send Option"> <br> </BODY> </HTML> <? if($deleted_url=="true") { setcookie("cookie_set","",time()-4600); echo"url's and cookie deleted";} else{ $url_modified=array($modified_url_1,$modified_url_2,$modified_url_3); $initial=unserialize(stripslashes($cookie_set)); $new_value=serialize($url_modified); $cookie_set=$new_value; echo"valorile initiale sunt:","<BR>"; foreach($initial as $key=>$value) {echo"$key:$value","<br>";} echo"valorile modificate sunt:","<br>"; $final=unserialize(stripslashes($cookie_set)); foreach($final as $key=>$value) echo"$key=>$value","<br>";} ?> |
(#904 2005-12-19 10:53:39) Post Reply |
|
Gixboy
|
Alright guys, this lesson got me mroe than any before, because it seriously calls for remembering everything you were taught, plus going out and doing some PHP learning on your own. It's a much more creative and thus individual assignment.
Some things about my script that you may want to know. First off, IT DOES WORK WITH PHP5. I don't think any of the other examples do. Second, my script limita the user to 15 favorites, but you can easily change that by going through all the loops and changing "$n < 15" to whatever number you want. Finally, there are two pages only because when you set a cookie, the page must refresh before you can see it. If you refresh the page though, it remembers not only the cookie, but also you submitting the url form. the resulting page will have the new link displayed, but it will also have an ERROR message saying you altready have that link. To avoid getting this spam error message, a second page is used called "refresher" in which the only code is a header leading to the HTTP_REFERER... in other words, right back where you started except without the error. Anyway, now you know how it works, but now also you can how it works :) This took me DAYS to perfect, so I hope you guys like it!! |
(#905 2005-12-23 15:16:10) Post Reply |
|
TDavid
|
Gixboy - you did a really nice job here. I must admit that I was surprised to see the qualiy of your work. Keep at it.
BTW, you are welcome back in the chatroom as long as you can not interupt and be rude to those who are trying to help you. |
(#906 2005-12-24 01:58:30) Post Reply |
|
Gixboy
|
thanks, but I was being naive when I said I "perfected" it. The eregi() web url function has a ? after the ^(http://) that should not be there. The way it is now, you can add something like "gixboy.com" instead of "http://gixboy.com" and that will ultimately make the link lead to http://gixboy.com/gixboy.com which, of course, doesn't exist.
Also, if you put that code into a browser, you'll notice that the first time you use the script, nothing will happen - you must use it again before it wakes up and realizes that it should be doing something. That can easily be fixed by just moving the if(!$_COOKIE['urls']) conditional ahead of if($_POST['action']=="true") conditional. You need to make those two changes for the code to work 100% properly. I did not realize either of those two because, respectively, I tested the false url by randomly typing in letters or leaving it blank, and I had been testing so much that the cookie was set, so I never retested the first time. It wasn't until I uploaded it onto my domain and tried to access it from another desktop that I realized what was happening. Besides those two little things, there are things that can be done to make the code shorter, that, after writing the thing for days, I was too lazy to go back and do. But it still works nonetheless. Thanks TD for your enthusiasm in the quality of my script, but for now I'm gonna fly solo when it comes to programming. I'll use the script school when I need to, and I'll post the assignments here like I have been, but I won't be asking questions in the chat anymore. As we saw today, at the point that I'm getting to, it's hard to phrase both a question and an answer in a way that both parties can understand. Between the time it takes to decipher one another's thoughts and to argue, I probably could have figured the problem out on my own by then. ~ Gix |
(#907 2005-12-28 15:10:39) Post Reply |
|
lestat
|
As far as 'nothing happening' goes, you may want to look back to week #8, where headers and redirection were covered.
But I'm sure you would have "figured that on your own"... |
(#979 2006-03-23 03:35:52) Post Reply |
|
Russell
|
this was a bugger :) thanks lestat for the live help. again, cant post a working url because i dont have any non-adult domains. and its on a server with php 4.4.0 not 5.0 :/ i guess theres things that will need to be changed when my server upgrades its php. ill figure those out when that happens.
|
(#980 2006-03-23 03:37:37) Post Reply |
|
Russell
|
p.s. i made it an all-in-one script :P |
|
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