2016-06-27 8 views
-2

こんにちは私はこのerorrsを取得していますが、私はどこに問題があるのか​​わかりません。 私はどんなアドバイスにも感謝します。phpmailer未定義の変数

注意:未定義の変数:Cでヘッダー:\ WAMP \ WWW \ restaurace \ kongresform.phpライン上の59

注意:未定義の変数:Cでmessageb:\ WAMP \ WWW \ restaurace \ kongresform.phpオンライン72

if (empty($errors)) { //If everything is OK 

     // send an email 
     // Obtain file upload vars 


     // Headers 
     $headers.= "From: $emailfr \n"; 
     $headers.= "BCC: $emailcc "; 

     // creates a boundary string. It must be unique 
      $semi_rand = md5(time()); 
      $mime_boundary = "==Multipart_Boundary_x{$semi_rand}x"; 

      // Add the headers for a file attachment 
      $headers .= "\nMIME-Version: 1.0\n" . 
         "Content-Type: multipart/mixed;\n" . 
         "boundary=\"{$mime_boundary}\""; 


      $messageb.="Dobrý den,<br>\n"; 

      $messageb.="Jméno a přijímení: <b>".$namefrom."</b><br>\n"; 
      $messageb.="Email: <b>".$email."</b><br>\n"; 

      $messageb.="Prostor pro poznámky: ".$message."<br><br>\n"; 
      $messageb.="S pozdravom<br>\n"; 
      $messageb.="tým Fincentrum Reality<br>\n"; 
      $messageb.="<br>\n"; 
      $messageb.="========================================================================<br>\n"; 
      $messageb.="Tento e-mail byl odeslaný automaticky z webu. Prosím, neodpovídejte na něj.<br>\n"; 
      $messageb.="========================================================================<br>\n"; 

     $subject="Potvrzení\n"; 





     // PHP Mailer 
     $mail = new PHPMailer; 

//$mail->SMTPDebug = 3;        // Enable verbose debug output 

$mail->isSMTP();          // Set mailer to use SMTP 
$mail->Host = 'smtp.gmail.com'; // Specify main and backup SMTP servers 
$mail->SMTPAuth = true;        // Enable SMTP authentication 
$mail->Username = '[email protected]';     // SMTP username 
$mail->Password = 'mattonirestaurace';       // SMTP password 
$mail->SMTPSecure = 'tls';       // Enable TLS encryption, `ssl` also accepted 
$mail->Port = 587;         // TCP port to connect to 

$mail->setFrom($emailfr); 
$mail->addAddress($to);  // Add a recipient 
//$mail->addReplyTo('[email protected]', 'Information'); 
//$mail->addCC($emailcc); 
$mail->addBCC($emailcc); 

//$mail->addAttachment('/var/tmp/file.tar.gz');   // Add attachments 
//$mail->addAttachment('/tmp/image.jpg', 'new.jpg'); // Optional name 
$mail->isHTML(true);         // Set email format to HTML 

$mail->Subject = $subject; 
$mail->Body = $messageb; 
$mail->CharSet = 'UTF-8'; 
//$mail->AltBody = 'This is the body in plain text for non-HTML mail clients'; 






     if(!$mail->send()) { 
      exit("Mail could not be sent. Sorry! An error has occurred, please report this to the website administrator.\n"); 
      //echo 'Mailer Error: ' . $mail->ErrorInfo; 
     } 
     else { 
      echo '<div id="formfeedback"><h3>Děkujeme za Vaší zprávu!</h3><p>'. $thanksmessage .'</p></div>'; 
      unset($_SESSION['yellloForm']); 
      print_form(); 

     } // end of if !mail 

    } 
+0

変更

$headers.= "From: $emailfr \n"; 

$headers = "From: $emailfr \n"; 

$messageb.="Dobrý den,<br>\n"; 

あなたはバリを初期化していませんそれらを追加する前にables。それぞれの最初のものを '='の代わりに '=' –

答えて

2

この:

$headers.= "From: $emailfr \n"; 

はこれと同じものです:

これを含ま

$headers . "From: $emailfr \n"; 

しかし、その時点で、$headersが定義されていません。したがって、存在しない変数から読み取ろうとしているため、エラーです。

ちょうどそれを定義するのではなく、それを使用しようとする$headersの使用の最初のインスタンスを変更します。

$headers = "From: $emailfr \n"; 

繰り返し$messagebのためにそれを同様に使用しています最初の行に。

+1

*のようにする必要があります。*最初の行で$ messagebのために繰り返します。* - 自分自身で作業をしなければならないとき自分自身のために、実際に行く方法とそれらをスプーフィングしない;-)良い答えデービッド。 –

-1

彼は初期化されていない変数に値を追加しようとしています。

$messageb ="Dobrý den,<br>\n"; 
+2

だから、なぜ彼らはそれをするべきですか?あなたが知っている理由があります。私たちを教えてください。 –

+0

彼は初期化されていない変数に値を追加しようとしています。 –

+0

私には(私はすでに「なぜ」が分かっているのか)教えてはいけません。あなたがここでコメントで言ったのはもともとあなたの答えの一部だったはずです。スタックプロフェッショナル:回答(可能な解決策)を掲示するとき、バットからすぐに「ヒット」して肯定的な票を集める。それはあなたがそれらにいるならば。 –