Logging Information

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
GRPsuper
Forum Newbie
Posts: 18
Joined: Fri Apr 14, 2006 9:47 pm

Logging Information

Post by GRPsuper »

hey, i was wondering if someone could help me with the code i will describe below.
this is what im trying to do:
i want to make a link called grpsuper9.stylehosting.com/log.php

and in that file, i want me to be able to do this

grpsuper9.stylehosting.com/log.php?username=GRPsuper9&password=hihihihi

then, i want the information that i typed "GRPsuper9" and "hihihihi" to be writting automaticly to this page

grpsuper9.stylehosting.com/logged.php

and each time i used this url grpsuper9.stylehosting.com/log.php?username=aaaa&password=bbbbb, it would stack the information in an array i guess... if thats what u call it. by an array, i mean it would stack it like this everytime i went to that url.

aaaa bbbbb
aaaa bbbbb
aaaa bbbbb
GRPsuper9 hihihihi

how would i do this?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

GRPsuper
Forum Newbie
Posts: 18
Joined: Fri Apr 14, 2006 9:47 pm

Post by GRPsuper »

thanks, that information seems sorta like i want. but cant anyone walk me through the steps? because im new to PHP and i dont quite get all of this stuff :(

edit: so i figured out i had to put this into my log.php file

<?php
$file = fopen('test.txt', 'a', 1);
$text="Your text to write\n";
fwrite($file, $text);
fclose($file);
?>


the above code is inserted into log.php. now my question comes to this, instead of just going to the page log.php and it writing it automaticly, how do i make it write WHAT I WANT it to write?

for instance, grpsuper9.stylehosting.com/log.php?message=i want it to log this

how would i make it log what i told it to do? and how would i make it so i would be able to write message in there and after message, it will log it?
malcolmboston
DevNet Resident
Posts: 1826
Joined: Tue Nov 18, 2003 1:09 pm
Location: Middlesbrough, UK

Post by malcolmboston »

Code: Select all

function writeLog ($text) {
    $file = fopen('test.txt', 'a', 1);
    fwrite($file, $text);
    fclose($file); 
}

//to call

writeLog ("write this text to file");
GRPsuper
Forum Newbie
Posts: 18
Joined: Fri Apr 14, 2006 9:47 pm

Post by GRPsuper »

thanks everyone, my issue has been solved :)
Post Reply