In the code below. The $fp1 is outputting two files one correct with the clients information and the other empty other than a $Refnumb string. Any ideas? I am pretty new to PHP, I am sure this is something nooby. Any help would be great! :)

$text = $_POST['first_name']; # Form must use POST.
$text1 = $_POST['last_name']; # Form must use POST.
$text2 = $_POST['email']; # Form must use POST.
$text3 = $_POST['telephone']; # Form must use POST.
$text4 = $_POST['comments']; # Form must use POST.

echo ("Service Inquiry submitted sucessfully! Thankyou, " . $text . " I will contact you shortly regarding your inquiry! - Derek (Owner of The Boro Tech) <br><br>");
echo ("<b>Customer Number:" . $Refnumb . "<br><br> Record this number.</b> If you continue with a computer service you can use this number to check the status of your service order.");

}
else {
echo ("File was not written");
}

?>

sunfighter

09-09-2011, 04:12 PM

The code reads correct. So I ran it and things worked the way you would think. The so and the requests directory had only one file written to them. The $fp1 only outputs a single file to the so dir.

BUT the second running of the code using the same form input strings does yield a file named last_namefirst_name1.txt

The third time this file is just over written

Gono

09-09-2011, 05:59 PM

Thanks for the reply. That's odd. I am still experiencing two files being put into the SO dir. With different filenames given to them by the rand_string function. One of them has all of the clients info. The other is formated but empty of data other than the Refnumb variable. So odd...

Fou-Lu

09-09-2011, 10:40 PM

Two runs = 2 files, but 3 runs = 2 files. Thats due to this line:

$filename = $mypath . $text1 . $text . + 1 . (".txt");

+ 1 simply indicates positive one, and always results in $mypath . $text1 . $text . '1.txt' as the name of the file. So if a collision exists it will instead overwrite a previously created file.

Can you clarify the problem a bit? The initial almosts sounds like you are indicating that the contents of the file are $Refnumb, but I don't see that as being the case in any of the code provided.

Gono

09-09-2011, 11:45 PM

Two runs = 2 files, but 3 runs = 2 files. Thats due to this line:

$filename = $mypath . $text1 . $text . + 1 . (".txt");

+ 1 simply indicates positive one, and always results in $mypath . $text1 . $text . '1.txt' as the name of the file. So if a collision exists it will instead overwrite a previously created file.

Can you clarify the problem a bit? The initial almosts sounds like you are indicating that the contents of the file are $Refnumb, but I don't see that as being the case in any of the code provided.

using a form that post's to my php script. I am getting two files in each directory (so and requests) In each directory I receive one correct file like: