Universal Form Validator PHP Support Product Page

Answered

Cannot send session cookie - headers already sent by

Asked 30 Jan 2012 15:37:49
3
have this question
30 Jan 2012 15:37:49 Jakob Miller posted:
Hi there,

i have a problem at this page:
www.arlberg-ferienwohnung.com/kontakt/index.php

Here ist the source-code:


<?php require_once('../ScriptLibrary/dmxValidator.php'); ?>
<?php
// Universal Form Validator PHP 1.5.5
$formcheck = new dmxValidator();
$formcheck->script_folder = "../ScriptLibrary";
$formcheck->cs_validate_on_change = false;
$formcheck->cs_validate_on_submit = true;
$formcheck->reenable_javascript = true;
$formcheck->use_bot_check = true;
$formcheck->report_type = 4;
$formcheck->error_font =  "Arial";
$formcheck->error_font_size = 12;
$formcheck->error_color = "#ffffff";
$formcheck->error_bold = true;
$formcheck->error_italic = false;
$formcheck->error_image = "";
$formcheck->error_fixed = "Custom";
$formcheck->error_padding = 4;
$formcheck->border_color = "#FF0000";
$formcheck->border_style = "solid";
$formcheck->css_error_file = "validatorError1";
$formcheck->error_bg_color = "#ff0000";
$formcheck->error_preset = "error_five.txt";
$formcheck->tooltip_position = "top";
$formcheck->css_hint_file = "validatorHint1";
$formcheck->hint_preset = "brown.txt";
$formcheck->hint_tooltip_position = "top";
$formcheck->hint_border_color = "#993300";
$formcheck->hint_border_style = "solid";
$formcheck->hint_bg_color = "#993300";
$formcheck->hint_text_color = "#ffff66";
$formcheck->hint_text_font = "Arial";
$formcheck->hint_text_size = 12;
$formcheck->hint_text_bold = false;
$formcheck->hint_text_italic = false;
$formcheck->hint_box_width = 200;
$formcheck->hint_image = "";
$formcheck->hint_fixed = "Custom";
$formcheck->hint_padding = 4;
$formcheck->use_custom_focus_class = "fixed";
$formcheck->focus_border_style = "groove";
$formcheck->focus_border_size = 2;
$formcheck->focus_border_color = "#C3D9FF";
$formcheck->focus_bg_color = "#FFFFFF";
$formcheck->focus_text_color = "#000000";
$formcheck->use_custom_valid_class = "fixed";
$formcheck->valid_border_style = "groove";
$formcheck->valid_border_size = 2;
$formcheck->valid_border_color = "#00FF00";
$formcheck->valid_bg_color = "#FFFFFF";
$formcheck->valid_text_color = "#000000";
$formcheck->use_custom_invalid_class = "fixed";
$formcheck->invalid_border_style = "groove";
$formcheck->invalid_border_size = 2;
$formcheck->invalid_border_color = "#FF0000";
$formcheck->invalid_bg_color = "#FFFFFF";
$formcheck->invalid_text_color = "#000000";
$formcheck->add_rule("anfrageformular", "Vorname", "allformats", ",,", "true", "", "", "", "");
$formcheck->add_rule("anfrageformular", "Nachname", "allformats", ",,", "true", "", "", "", "");
$formcheck->add_hint("anfrageformular", "Vorname", "Vorname bitte hier eintragen");
$formcheck->add_hint("anfrageformular", "Nachname", "Nachname bitte hier eintragen");
$formcheck->add_hint("anfrageformular", "Email", "Email zur Beantwortung Ihrer Anfrage");
$formcheck->validate();
?>
<?php
//Linecraft PHP Form mail v.1.2.0
if(isset($_POST["Senden"])){
	$mail_form="anfrageformular";
	$exception_fields=array("Senden");
	$to="info@arlberg-ferienwohnung.com";
	$from=$_POST['Email'];
	$cc="";
	$bcc="office@marketinghilfe.com";
	$host="";
	$username="";
	$password="";
	$subject="Anfrage von Homepage";
	$message_header="<p>Anfrage von arlberg-ferienwohnung.com: </p>";
	$message_footer="";
	$message_body="";
	$format_html="\r\nContent-type: text/plain; charset=utf-8";
	$html="1";
	$success_page="/kontakt/danke.php";
	$error_page="";
	$o_t="";
	$c_t="";
	$br="\n";
	//If HTML
	if($html=="1"){
		$o_t="[b]";
		$c_t="[/b]";
		$br="[br]";
		$format_html="\r\nContent-type: text/html; charset=utf-8";
	}
	foreach($_POST as $fieldName => $value){
		if(!in_array($fieldName,$exception_fields)){
			$fieldName=str_replace("_"," ",$fieldName);
			$message_body=$message_body.$o_t.$fieldName.$c_t.": ".$value.$br;
		}
	}
	$message=$message_header.$br.$message_body.$br.$message_footer;
	$upload_folder="";
	$attachment_exists = false;
	$attachment_field = "Kein";
	if($attachment_field!=""){
		if(isset($_FILES[$attachment_field]) && !empty($_FILES[$attachment_field]['name']) && $upload_folder != ""){
			$file_name = basename($_FILES[$attachment_field]['name']);
			if(!file_exists($upload_folder)){die("Upload folder doesn't exist");}				
			$file_extension = substr($file_name,strrpos($file_name, '.') + 1);
			$file_size = $_FILES[$attachment_field]["size"]/1024;
		
			$max_allowed_file_size = +0;
			$allowed_ext_string = "";
			$allowed_extensions = explode(",",$allowed_ext_string);

			if($file_size > $max_allowed_file_size*1048576 && $max_allowed_file_size > 0){
				die("Size of file should be less than $max_allowed_file_size.[br]The email could not be sent.");
			}
		
			$pathinfo = pathinfo($_FILES[$attachment_field]['name']);
			if(!in_array(strtolower($pathinfo['extension']),$allowed_extensions) && $allowed_ext_string!=""){
				die(strtoupper($pathinfo['extension'])." files are not allowed.[br]The email could not be sent.");
			}
						
			$file_path = $upload_folder . "/". $file_name;
			if(!move_uploaded_file($_FILES[$attachment_field]["tmp_name"], $file_path)){
				die("There has been an error while adding attachment.[br]The email could not be sent.");
			 }
			 $attachment_exists = true;
		}
	}
	@include_once "Mail.php";
	@include_once("Mail/mime.php");
	if(!class_exists('Mail') || !class_exists('Mail_mime')){
		$headers="From:".$from.$format_html;
		$headers.=($cc!="")?("\r\nCc: " . $cc):"";
		$headers.=($bcc!="")?("\r\nBcc: " . $bcc):"";
		if($attachment_exists){
			$file = fopen($file_path,'rb');
			$attachment = fread($file,filesize($file_path));
			fclose($file); 
			 
			$rand = md5(time());
			$mime_boundary = "==Multipart_Boundary_x{$rand}x"; 
			$headers.="\nMIME-Version: 1.0\nContent-Type: multipart/mixed;\n boundary=\"{$mime_boundary}\""; 
			$attachment_message = "This is a multi-part message in MIME format.\n\n--{$mime_boundary}$format_html\nContent-Transfer-Encoding: 7bit\n\n$message\n\n"; 			 
			$attachment = chunk_split(base64_encode($attachment)); 
			$attachment_message.= "--{$mime_boundary}\nContent-Type: {text/html};\n name=\"{$file_name}\"\nContent-Disposition: attachment;\n filename=\"{$file_name}\"\nContent-Transfer-Encoding: base64\n\n".$attachment."\n\n--{$mime_boundary}--\n";
			$message = $attachment_message;
		}else{
			$headers.= $format_html;		
		}
		if(mail($to, stripslashes($subject), stripslashes($message),$headers)){
			if($attachment_exists){unlink($file_path);}
			if($success_page!=""){
				header("Location:".$success_page);
			}
		}else{
			if($attachment_exists){unlink($file_path);}
			if($error_page!=""){
				header("Location:".$error_page);
			}
		}
	}else{
		if($cc!=""){$to.=", ".$cc;}
		if($bcc!=""){$to.=", ".$bcc;}
		if($host!="" && $username!="" && $password!=""){
			$contructor = Mail::factory('smtp',array ('host' => $host,'auth' => true,'username' => $username,'password' => $password));
		}else{
			$contructor = Mail::factory('mail');
		}
		$headers = array ('From' => $from,'To' => $to,'Subject' => $subject);
		if($cc!=""){$headers['Cc']=$cc;}
		$mime = new Mail_mime("\n");
		if($html=="1"){
			$mime->setHTMLBody($message);
		}else{
			$mime->setTXTBody($message);
		}
		if($attachment_exists){
			$mime->addAttachment($file_path);
		}
		$message = $mime->get();
		$headers = $mime->headers($headers);
		
		$mail = $contructor->send($to, $headers, $message);
		if($attachment_exists){unlink($file_path);}

		if (PEAR::isError($mail)){
			if($error_page!=""){
				header("Location:".$error_page);
			}else{
				die("Error: ".$mail->getMessage());
			}
		}else{
			if($success_page!=""){
				header("Location:".$success_page);
			}			
		}
	}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Kontaktadresse und Anfrageformular Ferienwohnung Weiland in Pettneu am Arlberg in Tirol</title>
<meta name="Description" content="Kontaktadresse und Anfrageformular Ferienwohnung Weiland in Pettneu am Arlberg in Tirol. Telefon-Nummer, Email-Adresse und Online-Anfrage, bzw. Buchung" />
<link href="../css/general.css" rel="stylesheet" type="text/css" />
<?php
$menue = "Kontakt"; 
$submenue = "";
?>
<?php require_once('../includes/analytics.php'); ?>
<link rel="stylesheet" type="text/css" href="/Styles/dmxCalendar2.css" />
<link rel="stylesheet" type="text/css" href="/Styles/jqueryui/sunny/sunny.css" />
<script type="text/javascript" src="/ScriptLibrary/jsvat.js"></script>
<script type="text/javascript" src="/ScriptLibrary/jquery-latest.pack.js"></script>
<script type="text/javascript" src="/ScriptLibrary/dmxCalendar2.js"></script>
<script type="text/javascript" src="/ScriptLibrary/dmxCalendar2/lang/German/jquery.ui.datepicker-de.js"></script>
<script type="text/javascript" src="/ScriptLibrary/jquery.inputHintBox.js"></script>
<script type="text/javascript" src="/ScriptLibrary/jquery.maskedinput-1.2.2.js"></script>
<script type="text/javascript" src="/ScriptLibrary/jquery.validate.min.js"></script>
<script type="text/javascript" src="/ScriptLibrary/dmx.jquery.validate.js"></script>
<script type="text/javascript" src="/ScriptLibrary/jquery.tooltip.min.js"></script>
<script type="text/javascript" src="/ScriptLibrary/jquery.hoverIntent.min.js"></script>
<link rel="stylesheet" href="../Styles/dmxValidator/validatorHint1.css" type="text/css" />
<link rel="stylesheet" href="../Styles/dmxValidator/validatorError1.css" type="text/css" />
<?php
// dmxValidatorJSStart
$formcheck->generate_javascript_and_css();
// dmxValidatorJSEnd
?>
<script src="../ScriptLibrary/jquery-latest.pack.js" type="text/javascript"></script>
<script src="../ScriptLibrary/jquery.inputHintBox.js" type="text/javascript"></script>
<script src="../ScriptLibrary/jquery.maskedinput-1.2.2.js" type="text/javascript"></script>
<script src="../ScriptLibrary/jquery.validate.min.js" type="text/javascript"></script>
<script src="../ScriptLibrary/dmx.jquery.validate.js" type="text/javascript"></script>
<script src="../ScriptLibrary/jsvat.js" type="text/javascript"></script>
<script src="../ScriptLibrary/jquery.hoverIntent.min.js" type="text/javascript"></script>
</head>
<body>
<a name="oben" id="oben"></a>
<table width="100%" border="0" cellpadding="0" cellspacing="0" id="cont" summary="Ferienwohnung in Pettneu am Arlberg in Tirol von Hannelore Weiland">
  <tr>
    <td id="logo"><a href="http://www.arlberg-ferienwohnung.com/">[img]/bilder/design/logo/logo-ferienwohnung-pettneu.jpg" width="240" height="250" alt="Ferienwohnung Weiland in Pettneu am Arlberg in Tirol - Österreich" /></a></td>
    <td id="top_img">[img]/bilder/oben/startseite/pettneu-winter-vollmondnacht.jpg" width="740" height="250" alt="Kontaktadresse und Anfrage an Ferienwohnung Weiland in Pettneu" /></td>
  </tr>
  <tr>
    <td colspan="2" id="nav"><?php require_once('../includes/navi.php'); ?></td>
  </tr>
  <tr>
    <td id="subnav"><?php require_once('../includes/subnav.php'); ?>
      <p>&nbsp;</p></td>
    <td id="inhalt"><table width="100%" border="0" cellpadding="0" cellspacing="0" id="texte" summary="Informationen zur Ferienwohnung in Pettneu am Arlberg von Hannelore Weiland">
        <tr>
          <td>[h1]Kontaktadresse und Anfrageformular [/h1]
            <p>F&uuml;r eine Kontaktaufnahme stehen wir Ihnen gerne per Telefon oder Email zur Verf&uuml;gung. <br />
              Falls Sie ein <strong>ausf&uuml;hrliches, verbindliches Angebot</strong> w&uuml;nschen, f&uuml;llen Sie bitte das auf dieser Seite befindliche <a href="/kontakt/index.php#kontaktformular" title="Durch anklicken zum Anfrageformular springen">Anfrageformular</a> aus. </p>
            <table border="0" cellpadding="0" cellspacing="0" id="adresse" summary="Adresse und Telefon">
              <tr>
                <td width="50%" id="address"><strong>Adresse: </strong></td>
                <td width="50%" id="kontakt"><strong>Kontakt: </strong></td>
              </tr>
              <tr>
                <td>Hannelore Weiland <br />
                  Reschenwiese 316 <br />
                  A-6574 Pettneu am Arlberg </td>
                <td><p>Telefon: 0043 664 353 99 65 </p>
                  <p>Email: <a href="mailto:info@arlberg-ferienwohnung.com" title="Email senden an info@arlberg-ferienwohnung.com (Hannelore Weiland)">info@arlberg-ferienwohnung.com</a> </p></td>
              </tr>
            </table>
            <p><a name="kontaktformular" id="kontaktformular"></a></p></td>
        </tr>
        <tr>
          <td></td>
        </tr>
        <tr>
          <td></td>
        </tr>
        <tr>
          <td><form id="anfrageformular" name="anfrageformular" method="post" action="">
            <table border="0" cellpadding="0" cellspacing="0" id="anfrage" summary="Anfrageformular Ferienwohnung Hannelore Weiland in Pettneu am Arlberg in Tirol">
              <tr>
                <td colspan="2">[h4]Anfrageformular [/h4]
                  <p>Um Ihnen ein verbindliches Angebot machen zu k&ouml;nnen, f&uuml;llen Sie bitte die mit einem roten Sternchen gekennzeichneten Felder aus. <br />
                    Wir verwenden Ihre Daten nur zur Beantwortung Ihrer Anfrage. </p></td>
              </tr>
              <tr>
                <td width="50%">Vorname: <span id="sternchen">*</span> <br />
                  <label for="Vorname"></label>
                  <label for="Vorname"></label>
                  <input name="Vorname" type="text" class="textfeld" id="Vorname" value="<?php echo dmxSetValue("", "Vorname") ?>" />
                  <?php $formcheck->generate_error("anfrageformular","Vorname","requiredcond",",,");$formcheck->generate_error("anfrageformular","Vorname","allformats",",,");?>
                  <br />
                  <label for="Vorname"></label></td>
                <td width="50%">Nachname: <span id="sternchen">*</span><br />
                  <label for="Nachname"></label>
                  <input name="Nachname" type="text" class="textfeld" id="Nachname" value="<?php echo dmxSetValue("", "Nachname") ?>" />
                  <?php $formcheck->generate_error("anfrageformular","Nachname","requiredcond",",,");$formcheck->generate_error("anfrageformular","Nachname","allformats",",,");?></td>
              </tr>
              <tr>
                <td>Adresse: <br />
                  <label for="Strasse"></label>
                  <input name="Adresse" type="text" class="textfeld" id="Adresse" value="<?php echo dmxSetValue("", "Adresse") ?>" /></td>
                <td>&nbsp;</td>
              </tr>
              <tr>
                <td>Postleitzahl: <br />
                  <label for="PLZ"></label>
                  <input name="PLZ" type="text" class="textfeld" id="PLZ" value="<?php echo dmxSetValue("", "PLZ") ?>" />
                  <br /></td>
                <td>Ort / Stadt: <br />
                  <label for="Ort"></label>
                  <input name="Ort" type="text" class="textfeld" id="Ort" value="<?php echo dmxSetValue("", "Ort") ?>" />
                  <br /></td>
              </tr>
              <tr>
                <td>Ihre Email-Adresse: <span id="sternchen">*</span> <br />
                  <label for="Email"></label>
                  <input name="Email" type="text" class="textfeld" id="Email" />
                  </td>
                <td> Telefon: <br />
                  <label for="Telefon"></label>
                  <input name="Telefon" type="text" class="textfeld" id="Telefon" value="<?php echo dmxSetValue("", "Telefon") ?>" />
                  <br /></td>
              </tr>
              <tr>
                <td></td>
                <td></td>
              </tr>
              <tr>
                <td>Anreisedatum: <span id="sternchen">* </span><br /></td>
                <td>Abreisedatum: <span id="sternchen">* </span></td>
              </tr>
              <tr>
                <td>Besondere W&uuml;nsche: <br />
                  <label for="Nachricht"></label>
                  <textarea name="Nachricht" cols="35" rows="6" class="textfeld" id="Nachricht"><?php echo dmxSetValue("", "Nachricht") ?></textarea></td>
                <td>&nbsp;</td>
              </tr>
              <tr>
                <td><p>&nbsp;</p></td>
                <td><p>
                  <input name="Senden" type="submit" class="textfeld" id="Senden" value="Anfrage absenden" />
                </p>
                  <p>&nbsp; </p></td>
              </tr>
            </table>
            <?php $formcheck->show_bot_check_error(); ?>
          </form></td>
        </tr>
        <tr>
          <td></td>
        </tr>
      </table></td>
  </tr>
  <tr>
    <td colspan="2" id="unten"><?php require_once('../includes/footer.php'); ?></td>
  </tr>
</table>
</body>
</html>



Any idea?

Hoping for a solution,
Jakob

Replies

Replied 06 Jun 2012 12:33:22
06 Jun 2012 12:33:22 reinhardt ellis replied:
Just add


<?php session_start(); ?>


to the top of your page.. thanks MIRO
Replied 03 Jul 2013 09:17:20
03 Jul 2013 09:17:20 Kenny Darcy replied:
Thank you <?php session_start(); ?> has worked for me just now. Can I ask why this is not applied by the extension itself. Do I need to keep snippets aside for when needing to use this extension.

Cheers

Kenny

Reply to this topic