Hi

Just changed my web hosting from Windows to Linux.

Sorted out most problems, but trying to get my contact form to work.






below shows the related HEADER code

Code ...
<?php ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<?php
$RootName = $SERVER['DOCUMENT_ROOT'];
$FolderName = "formdata/";
$FullFolderName = $RootName . "/" . $FolderName;
$dateYmd = date('Ymd');
$DateTime = date('Ymd') . " " . date('H:i');

$FileName = "Contact_data.txt";
// $FileName = $dateYmd . "
Contact.txt";

$File_Name = "../" . $FolderName . "/" . $FileName;
$FullFileName = $RootName . "/" . $File_Name;
// +++++++++++++++++++++++++++++++++++++++ ++++++++++++++++++++++++++

// Form Validation ...
$cError = "";

$cTxtStr = trim($POST['cTxt']);
$name_pat = "/[a-z .'-]+$/i";
if ( (!isset($
POST['cFname'])) || ($POST['cFname'] == "") )

{
$cError .= 'First Name must be given <br />';
}
elseif ( !preg_match($name_pat,$
POST['cFname']) )
{
$cError .= 'First Name entered does not appear to be valid. <br />';
}

if ( (!isset($POST['cSname'])) || ($POST['cSname'] == "") )

{
$cError .= 'Surname must be given <br />';
}
elseif ( !preg_match($name_pat,$_POST['cSname']) )
{
$cError .= 'Surname entered does not appear to be valid. <br />';
}

if ( (!isset($POST['cMail'])) || (trim($POST['cMail']) == "") )
{
$cError .= "Email address must be given <br />";
}
else
{
$mail = stripslashes($POST['cMail']);
$mail_pat = "/[
.0-9a-zA-Z-]+@([0-9a-zA-Z][0-9a-zA-Z-]+.)+[a-zA-Z]{2,6}$/i";
if ( !preg_match($mail_pat, $mail) )
{
$cError .= "Email address is invalid. <br />";
}

}

if( strlen($cTxtStr) < 2 )
{
$cError .= "Please type your message. <br />";
}

if ( ($cError == "") OR ($cError == NULL) )
{
$file_record = NULL;
$file_record = $POST['cFname'] . " " . $POST['cSname'] . " " . "\r\n";
$file_record .= $POST['cMail'] . " " . "\r\n";
$file_record .= $
POST['cTxt'] . " " . "\r\n";
$file_record .= " ...... ... " . $DateTime . " ";

$file_record .= "\r\n";
$file_record .= "++++++++++++++++++++++++++++++++++++++" . "\r\n" . "\r\n";

// $FileToOpen = $FullFileName;

$FileToOpen = $FolderName . $FileName;
// echo ("About to open ");
// echo ($FileToOpen);
// echo (" ... ");

$open_file = fopen($FileToOpen,"a+") or die("Cant open the file");
fwrite($open_file, $file_record); // write a record
fclose($open_file);
$cError = "";

// header("Location: www.probowluk.co.uk/Contact_Done.php"); //

// Send the "301 Moved Permanently" status code first.
header("HTTP/1.1 301 Moved Permanently");
//Redirect the browser ...
header("location: http://www.probowluk.co.uk/Contact_Done.php");
exit();
} ELSE {
$file_record = NULL;
$file_record = $cError . " " . "\r\n";
$file_record .= " ...... ... " . $DateTime . " ";

$file_record .= "\r\n";
$file_record .= "+++++++ ++++++ +++++++++ +++++++" . "\r\n" . "\r\n";

$FileToOpen = $FolderName . $FileName;

$open_file = fopen($FileToOpen,"a+") or die("Cant open the file");
fwrite($open_file, $file_record); // write error report into the file

fclose($open_file);

$cError = NULL;
// echo "++++ COMPLETED ! ++++";

}
?>
<html xmlns="http://www.w3.org/1999/xhtml">

<head>

    Anything not within <?php...?> tags will generate output, which will cause headers to be sent, so you need to move the doctype declaration to a point after you do your header() call (and also make sure there is nothing -- including whitespace -- before the opening <?php tag).

      Write a Reply...