snlildude87
Mar 8 2005, 10:32 PM
| | Does anyone know how to get a portion of the URL, record it somewhere, and display it later? For example, for something like index.php?name=blah, "blah" would be taken out, recorded, and displayed wherever you want it to.
That was a terrible explanation, but imagine those AIM subprofiles where each time a user visits, it remembers who you are and how many times you've visited.
Thank you in advance! |
Reply
millertime
Mar 8 2005, 10:35 PM
i used to know how to do that. i know it would end up being $blah and you take the value from that
Reply
beeseven
Mar 8 2005, 11:31 PM
If the URL was "myfile.php" and they typed "myfile.php?hello=yes" then in the PHP code you do this: CODE <?php $hello = $_GET['hello']; echo "hello = " . $hello; ?> And the output will be "hello = yes"
Reply
snlildude87
Mar 9 2005, 01:02 AM
OOO!! I'd have to try that sometime. Now, how would you store $hello so you can use it some other time?
Reply
beeseven
Mar 9 2005, 02:31 AM
If you mean a file, you can do this: CODE <?php $hello = $_GET['hello']; $file = "info.txt"; $handle = fopen($file, 'a'); //Says to open file (or create file) for writing and starts the pointer at the end if(!fwrite($handle,$hello)) //If it can't write { echo "Could not save information"; } else { echo "Information saved!"; } fclose($handle); //Closes file connection ?>
Reply
millertime
Mar 9 2005, 03:06 AM
wow, i'm going to have to try that sometime too. looks pretty simple
Reply
snlildude87
Mar 15 2005, 01:59 AM
QUOTE(beeseven @ Mar 8 2005, 11:31 PM) If you mean a file, you can do this: CODE <?php $hello = $_GET['hello']; $file = "info.txt"; $handle = fopen($file, 'a'); //Says to open file (or create file) for writing and starts the pointer at the end if(!fwrite($handle,$hello)) //If it can't write { echo "Could not save information"; } else { echo "Information saved!"; } fclose($handle); //Closes file connection ?> It turns out this is not simple as it seems - not for me, at least. This is what I did: 1. Created a blank info.txt file 2. Created a blah.php file (I chose a random name) 3. Copied your code above to blah.php 4. Saved blah.php 5. Uploaded info.txt to my public_html/www folder 6. Uploaded blah.php to my public_html/www folder 7. Changed info.txt's and blah.php's permissions to 777 - just in case 8. Went to sang.trap17.com/blah.php&hello=yes 9. The browser redirected me to my custom 404 error page Is there a step I'm missing in this seemingly easy process because my PHP knowledge is severly limited? Please post a reply. Thank you!
Reply
beeseven
Mar 16 2005, 11:03 PM
Sorry, didn't see this. When you're putting a variable in the address bar, the first variable has to be after a question mark, not an ampersand. Each subsequent variable is after an ampersand. Like this: site.trap17.com/blah.php ?hello=yes &goodbye=no &sixtimesnine=42
Reply
snlildude87
Mar 17 2005, 01:30 AM
Bee! I got the page to work...all by myself!  No offense to you of course. I went to the library and checked out a book called Sams Teach Yourself PHP4 in 24 Hours. There is a section in there on how to read and write files, so I used their examples as a guide for my own code. Of course, I used your code as a template. Here is the final code that works: CODE <?php $hello = $_GET["name"]; $file = "info.txt"; $handle = fopen($file, "a"); //Says to open file (or create file) for writing and starts the pointer at the end fwrite($handle, $hello); //takes whatever is in the address bar and append to info.txt fwrite($handle, ";\n"); //adds a newline fclose($handle); //Closes file connection ?>
I created a info.txt and placed it in the same directory as my blah.php file. Aren't you proud of me? I have barely no knowledge of PHP whatsoever! Man, I'm excited!
Reply
beeseven
Mar 17 2005, 02:01 AM
Some of the first things I did were with fwrite, it's a pretty neat command. Maybe soon you'll be coding a forum with a flat file database like me =O I gave up on that though when I came to Trap17, becausee mySQL is a lot easier.
Reply
Similar Topics
Keywords : recording portion address aim subprofiles features- Encode Your Email Address
- Confuse the Spam Bots, but not your viewing clients (5)
- Address Book In Php
- name card record (2)
hello, is there any php script which is likely Address bookmark. the idea is that i wanna do for my
school site, community group... so each people come and visited the site, they can key in; their
name, which course, address, contact, put photo(small tumb), course of study (if graduate), ect.. so
i wanna let this field editable.. so that next people come and visit they can view and they can put
also....even if graduate.. i was thinking to use with some sort of CMS.... so is their any good
script or any CMS support this funtion/MOD.. thks in advance......
Looking for recording, portion, address, bar, similar, aim, subprofiles, features
|
|
Searching Video's for recording, portion, address, bar, similar, aim, subprofiles, features
|
advertisement
|
|