문제

확인란을 선택하지 않고 제출하면 이러한 오류가 발생했습니다.

Warning: implode() [function.implode]: Invalid arguments passed in /home/content/o/l/t/oltvcb/html/feedback_mtg.php on line 148

Warning: Cannot modify header information - headers already sent by (output started at /home/content/o/l/t/oltvcb/html/feedback_mtg.php:148) in /home/content/o/l/t/oltvcb/html/feedback_mtg.php on line 162

양식 데이터가 실제로 내 이메일에 들어온 것을 알았습니다 ...

"옵션"필드와 관련이 있습니다.

아래는 양식 코드입니다.

#<?php
// ------------- CONFIGURABLE SECTION ------------------------

// $mailto - set to the email address you want the form
// sent to, eg
//$mailto       = "youremailaddress@example.com" ;

$mailto = 'xxxxx@xxxxxxxxx.com' ;

// $subject - set to the Subject line of the email, eg
//$subject  = "Feedback Form" ;

$subject = "Request For Visitor Guide" ;

// the pages to be displayed, eg
//$formurl      = "http://www.example.com/feedback.html" ;
//$errorurl     = "http://www.example.com/error.html" ;
//$thankyouurl  = "http://www.example.com/thankyou.html" ;

$formurl = "http://www.example.com/requestform_mtg.php" ;
$errorurl = "http://www.example.com/error.php" ;
$thankyouurl = "http://www.example.com/thankyou.php" ;

$email_is_required = 1;
$name_is_required = 1;
$address_is_required = 1;
$contactname_is_required = 1;
$city_is_required = 1;
$zip_is_required = 1;
$phone_is_required = 1;
$uself = 0;
$use_envsender = 0;
$use_webmaster_email_for_from = 1;
$use_utf8 = 1;

// -------------------- END OF CONFIGURABLE SECTION ---------------

$headersep = (!isset( $uself ) || ($uself == 0)) ? "\r\n" : "\n" ;
$content_type = (!isset( $use_utf8 ) || ($use_utf8 == 0)) ? 'Content-Type:
text/plain; charset="iso-8859-1"' : 'Content-Type: text/plain; charset="utf-8"' ;
if (!isset( $use_envsender )) { $use_envsender = 0 ; }
$envsender = "-f$mailto" ;
$name = $_POST['name'] ;
$contactname = $_POST['contactname'] ;
$title = $_POST['title'] ;
$email = $_POST['email'] ;
$address = $_POST['address'] ;
$city = $_POST['city'] ;
$state = $_POST['state'] ;
$zip = $_POST['zip'] ;
$country = $_POST['country'] ;
$fax = $_POST['fax'] ;
$phone = $_POST['phone'] ;
$mtgname = $_POST['mtgname'] ;
$dates = $_POST['dates'] ;
$attendance = $_POST['attendance'] ;
$guestroom = $_POST['guestroom'] ;
$mtgroom = $_POST['mtgroom'] ;
$timeframe = $_POST['timeframe'] ;
$options = $_POST['options'] ;
$comments = $_POST['comments'] ;
$http_referrer = getenv( "HTTP_REFERER" );

if (!isset($_POST['email'])) {
header( "Location: $formurl" );
exit ;
}
if (($email_is_required && (empty($email) || !ereg("@", $email))) ||
($name_is_required && empty($name)) || ($address_is_required && empty($address)) ||
($contactname_is_required && empty($contactname)) || ($city_is_required &&
empty($city)) || ($zip_is_required && empty($zip)) || ($phone_is_required &&
empty($phone))) {
header( "Location: $errorurl" );
exit ;
}
if ( ereg( "[\r\n]", $name ) || ereg( "[\r\n]", $email ) || ereg( "[\r\n]", $address
) || ereg( "[\r\n]", $contactname ) ) {
header( "Location: $errorurl" );
exit ;
}
if (empty($email)) {
$email = $mailto ;
}
$fromemail = (!isset( $use_webmaster_email_for_from ) ||
($use_webmaster_email_for_from == 0)) ? $email : $mailto ;

if (get_magic_quotes_gpc()) {
$comments = stripslashes( $comments );
}

$messageproper =
"This message was sent from:\n" .
"$http_referrer\n" .
"------------------------------------------------------------\n" .
"Organization Name: $name\n" .
"Contact Name: $contactname\n" .    
"Email of sender: $email\n" .
"Address of sender: $address\n" .
"City of sender: $city\n" .
"State of sender: $state\n" .
"Zip Code of sender: $zip\n" .
"Country of sender: $country\n" .           
"Fax of sender: $fax\n" .   
"Phone of sender: $phone\n" .
"Meeting Name: $mtgname\n" .            
"Preferred Dates: $dates\n" .           
"Expected Attendance: $attendance\n" .          
"Guest Rooms: $guestroom\n" .
"Largest Meeting Room Needed: $mtgroom\n" .             
"Decision Timeframe: $timeframe\n" .
"Options:".implode("\n",$options)."\n".                             
"------------------------- COMMENTS -------------------------\n\n" .
$comments .
"\n\n------------------------------------------------------------\n" ;
$headers =
"From: \"$name\" <$fromemail>" . $headersep . "Reply-To: \"$name\" <$email>" .
$headersep . "X-Mailer: chfeedback.php 2.13.0" .
$headersep . 'MIME-Version: 1.0' . $headersep . $content_type ;

if ($use_envsender) {
mail($mailto, $subject, $messageproper, $headers, $envsender );
}
else {
mail($mailto, $subject, $messageproper, $headers );
}
header( "Location: $thankyouurl" );
exit ;

?>
도움이 되었습니까?

해결책

심각하게 끔찍한 코드라는 사실 외에도 오류를 해결하려면이 줄을 바꾸십시오.

$options = $_POST['options'] ;

이것으로 :

$options = array();
if(isset($_POST['options'])) {
    $options = $_POST['options'];
}

기본적으로 옵션을 선택하지 않을 때마다 오류가 발생합니다. $options 배열로 설정되지 않으므로 시도 할 때 implode 그것에 PHP는 배열을 기대하기 때문에 불행합니다.

다른 팁

if (isset($_POST['options'])
{
    implode(...)
}

나는 이것과 함께 간다 .... 이것은 하나의 기능으로 모든 것을 캡슐화한다.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top