Gono
09-09-2011, 04:12 AM
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! :)
function rand_string( $length ) {
$str = " ";
$chars = "0123456789";
$size = strlen( $chars );
for( $i = 0; $i < $length; $i++ ) {
$str .= $chars[ rand( 0, $size - 1 ) ];
}
return $str;
}
$Refnumb = rand_string( 5 );
$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.
$mypathso = ".\\so\\";
$mypath = ".\\requests\\";
$filename =$mypath . $text1 . $text . (".txt");
$sofilename =$mypathso . $Refnumb . (".txt");
if (file_exists($filename) == true)
{
$filename = $mypath . $text1 . $text . + 1 . (".txt");
}
else{
}
$supertext = ("First Name:") . $text . " \r\n" . ("Last Name:") . $text1 . " \r\n" . ("Contact Number:") . $text3 . " \r\n" . ("Email Address:") . $text2 . " \r\n" . ("Customer Number:") . $Refnumb ." \r\n" . ("Status: N/A") . " \r\n" . ("Details: N/A") . " \r\n" . ("Problem:") . " \r\n" . " \r\n" . $text4;
$fp = fopen ($filename, "w");
if ($fp) {
fwrite ($fp, $supertext);
fclose ($fp);
}
$fp1 = fopen ($sofilename, "w");
if ($fp1) {
fwrite ($fp1, $supertext);
fclose ($fp1);
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");
}
?>
function rand_string( $length ) {
$str = " ";
$chars = "0123456789";
$size = strlen( $chars );
for( $i = 0; $i < $length; $i++ ) {
$str .= $chars[ rand( 0, $size - 1 ) ];
}
return $str;
}
$Refnumb = rand_string( 5 );
$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.
$mypathso = ".\\so\\";
$mypath = ".\\requests\\";
$filename =$mypath . $text1 . $text . (".txt");
$sofilename =$mypathso . $Refnumb . (".txt");
if (file_exists($filename) == true)
{
$filename = $mypath . $text1 . $text . + 1 . (".txt");
}
else{
}
$supertext = ("First Name:") . $text . " \r\n" . ("Last Name:") . $text1 . " \r\n" . ("Contact Number:") . $text3 . " \r\n" . ("Email Address:") . $text2 . " \r\n" . ("Customer Number:") . $Refnumb ." \r\n" . ("Status: N/A") . " \r\n" . ("Details: N/A") . " \r\n" . ("Problem:") . " \r\n" . " \r\n" . $text4;
$fp = fopen ($filename, "w");
if ($fp) {
fwrite ($fp, $supertext);
fclose ($fp);
}
$fp1 = fopen ($sofilename, "w");
if ($fp1) {
fwrite ($fp1, $supertext);
fclose ($fp1);
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");
}
?>