2013-04-23 3 views
-2

이것은 웹 사이트에서 양식에 대해 가지고있는 PHP 코드입니다. '우리 식당에서 특별한 행사와 행사에 관한 정보를 보내 주시겠습니까?' 양식의 예 또는 아니오 라디오 버튼입니다.버튼을 선택하면 추가 전자 메일로 보냅니다.

양식 사용자가 "예"버튼을 선택하면 추가 이메일을 다른 사람에게 보내고 싶습니다.

NO를 선택하거나 비워두면 전자 메일은 주 전자 메일 주소로만 보내고 추가 사람은 보내지 않습니다. 나는 이것을 며칠 동안 피하고, 코드가 완전히 탈출했다. 내가 얻을 수있는 도움은 크게 감사 할 것이다.

<?php 
if($_POST){ 

$p = $_POST["mailer"]; 
$body = "Email: ".$p['Email']."\n"; 
$body .= "First Name: ".$p['FirstName']."\n"; 
$body .= "Last Name: ".$p['LastName']."\n"; 
$body .= "Address: ".$p['Address']."\n"; 
$body .= "City: ".$p['City']."\n"; 
$body .= "State: ".$p['State']."\n"; 
$body .= "Zip: ".$p['Zip']."\n"; 
$body .= "Telephone: ".$p['Telephone']."\n"; 
$body .= "Date/Time: ".$p['Date and Time of Visit']."\n"; 
$body .= "Occassion: ".$p['Occasion']."\n"; 
$body .= "Restaurant and Location: ".$p['Restaurant and Location']."\n"; 
$body .= "Server: ".$p['Server\'s Name']."\n\n"; 
$body .= "Ratings:\n- Host Greeting: ".$p['Host Greeting']."\n"; 
$body .= "- Food Quality/Appeal: ".$p['Food Quality/Appeal']."\n"; 
$body .= "- Menu Selection: ".$p['']."\n"; 
$body .= "- Service: ".$p['Service']."\n"; 
$body .= "- Atmosphere: ".$p['Atmosphere']."\n"; 
$body .= "- Price/Value: ".$p['Price/Value']."\n"; 
$body .= "- Cleanliness: ".$p['Cleanliness']."\n"; 
$body .= "- Overall Experience: ".$p['Overall Experience']."\n\n"; 
$body .= "Questions:\n- - Will you recommend this restaurant to others? ".$p['Will you recommend this restaurant to others?']."\n"; 
$body .= "- Have you been to a BHG Restaurant before? ".$p['Have you been to a BHG Restaurant before?']."\n"; 
$body .= "- Would you be interested in receiving information about our private meeting/dining facilities and services? ".$p['']."\n"; 
$body .= "- May we send you information about special events and occasions at our restaurants? ".$p['May we send you information about special events and occasions at our restaurants?']."\n\n"; 
$body .= "Comments: \n".$p['How can we serve you better?']."\n"; 
if(!empty($_POST['url'])){ die('Thankyou'); } 
if(isset($_POST['url']) && $_POST['url'] == '') 

$to = "[email protected]"; 


$subject = "You have a feedback "; 

$message = $body; 

$from = "[email protected]"; 

$headers = "From:" . $from; 

$dbaddress = ''; 
$dbuser  = ''; 
$dbpass  = ''; 
$dbname  = ''; 

    try{ 
     $dbcnx    = mysql_connect($dbaddress,$dbuser,$dbpass) or die("Could not connect: " . mysql_error()); 
     mysql_select_db($dbname, $dbcnx) or die ('Unable to select the database: ' . mysql_error()); 
     $query    = mysql_query("insert into feedback (FirstName, LastName, Email, Address, City, State, Zip, Telephone, TimeandDay, Occassion, ResturantAndLocation, ServerName, HostGreeting, FoodQuality, Service, Atmosphere, PriceValue, Clenliness, OverallExperience, QuestionOne, QuestionTwo, QuestionFour, Comments, tstamp, responded) values ('".mysql_real_escape_string($p['FirstName'])."', '".mysql_real_escape_string($p['LastName'])."', '".mysql_real_escape_string($p['Email'])."', '".mysql_real_escape_string($p['Address'])."', '".mysql_real_escape_string($p['City'])."', '".mysql_real_escape_string($p['State'])."', '".mysql_real_escape_string($p['Zip'])."', '".mysql_real_escape_string($p['Telephone'])."', '".mysql_real_escape_string($p['Date and Time of Visit'])."', '".mysql_real_escape_string($p['Occasion'])."', '".mysql_real_escape_string($p['Restaurant and Location'])."', '".mysql_real_escape_string($p['Server\'s Name'])."', '".mysql_real_escape_string($p['Host Greeting'])."', '".mysql_real_escape_string($p['Food Quality/Appeal'])."', '".mysql_real_escape_string($p['Service'])."', '".mysql_real_escape_string($p['Atmosphere'])."', '".mysql_real_escape_string($p['Price/Value'])."', '".mysql_real_escape_string($p['Cleanliness'])."', '".mysql_real_escape_string($p['Overall Experience'])."', '".mysql_real_escape_string($p['Will you recommend this restaurant to others?'])."', '".mysql_real_escape_string($p['Have you been to a BHG Restaurant before?'])."', '".mysql_real_escape_string($p['May we send you information about special events and occasions at our restaurants?'])."', '".mysql_real_escape_string($p['How can we serve you better?'])."', now(), null) ;", $dbcnx) or die("Unable to validate login and password with the database:" . mysql_error());    
    }catch (Excetion $e){} 

mail($to,$subject,$message,$headers); 

header('Location: '); 
} 
else 
{ 
header('Location: '); 
} 
?> 
+0

'$ body ='를 한 번만 입력 할 수 있습니다. –

답변

0

추가 주소로 보내야 할 경우 세미콜론 (;)으로 구분 된 $ 변수에 추가 주소를 추가하기 만하면됩니다.

+0

고마워,하지만 특정 라디오 버튼 선택에 따라 조건부로 추가 이메일 만 필요합니다. – Byron

0
if ($_POST['confirm']=='yes'){ //assumes check box name is 'confirm' and value is 'yes' 
//new email 
} 
+0

답장을 보내 주셔서 감사합니다. 아직 고민 중입니다. 어쩌면 코드를 어디에 삽입해야하는지 모르겠다. 라디오 버튼 이름은 우리 식당에서 특별 이벤트 및 행사에 대한 정보를 보내 주시겠습니까? [ '식당에서 특별한 행사와 행사에 관한 정보를 보내 주시겠습니까?'] 값은 예 또는 아니오입니다. 또한 숨겨진 필드가 채워지거나 비어 있다면 앞으로 죽거나 앞으로 나아갈 수있는 변수가 있습니다. 다른 조언은 크게 감사하겠습니다. – Byron

관련 문제