try these changes...I put some comments where I thought they might help you understand what I changed...
<?php
$accountname = $_POST['accountname'];
$phone = $_POST['phone'];
$fax = $_POST['fax'];
$cell = $_POST['cell'];
$add1 = $_POST['add1'];
$add2 = $_POST['add2'];
$city = $_POST['city'];
$state = $_POST['state'];
$zip = $_POST['zip'];
$data = "$accountname \n $phone \n $fax \n $cell \n $add1 \n $add2 \n $city \n $state \n $zip \n";
$ending = ".txt";
$filename = "$accountname$ending";
//strings are only interpolated in double quotes! do not use single quotes if placing variables in strings.
//'$filename' = $filename
//"$filename" = the contents of $filename
if (file_exists("$filename"))//check for file in this directory
{
echo "The accountname $accountname already exists.";
}
else
{
//open file handle in this directory
$handle = fopen($filename, 'x+');
//write to handle
fwrite($handle, $data);
//close file handle
fclose($handle);
//the next line will echo regardless if what it says is true...
echo "Data Stored Successfully";
}
?> johnsquibb
Junior Poster in Training
84 posts since Nov 2007
Reputation Points: 14
Solved Threads: 14