2013-10-12 4 views
0

입력 한 양식 데이터를 기반으로 사용자에게 전자 메일을 보내는 PHP 스크립트가 있습니다. 그러나 문자열에 변수를 포함하면 모든 전자 메일은 "0"입니다.PHP 메일 기능이 제대로 작동하지 않습니다.

<?php 
    $u_name = $_POST['u_name']; 
    $email = $_POST['email']; 
    $password = $_POST['password']; 
    $to = $_POST['email']; 
    $subject = "Site Activation"; 
    $message = "Hello " + $u_name + ","; 
    $from = "[email protected]"; 
    $headers = "From:" . $from; 
    mail($to,$subject,$message,$headers); 
    echo "Mail Sent."; 
?> 

답변

2

PHP는 "+"use "."가 포함 된 문자열을 추가하지 않습니다. concat 문자열의 경우.

고정 코드 :

<?php 
    $u_name = $_POST['u_name']; 
    $email = $_POST['email']; 
    $password = $_POST['password']; 
    $to = $_POST['email']; 
    $subject = "Site Activation"; 
    $message = "Hello " . $u_name . ","; 
    $from = "[email protected]"; 
    $headers = "From:" . $from; 
    mail($to,$subject,$message,$headers); 
    echo "Mail Sent."; 
?> 
0

@MahdiParsa는 PHP의 연결이 . 이루어집니다 그러나 다음은 (각자의 취향의 따라 다름) 드 당신은뿐만 아니라 할 수 있습니다 말했다 것처럼 :

$firstVariable = "Hey"; 
$secondVariable = "How are you?"; 

$mixedVariable1 = $firstVariable . ' Alex! ' . $secondVariable; 
$mixedVariable2 = "$firstVariable Alex! $secondVariable"; 
$mixedVariable3 = "{$firstVariable} Alex! {$secondVariable}"; 
    // $mixedVariable3 is the same as $mixedVariable2, 
    // only a different type of Variable Substitution 
    // Take a look at: 
    // http://framework.zend.com/manual/1.12/en/coding-standard.coding-style.html 

http://codepad.org/1aYvxjiC

관련 문제