PHP 的奇怪故障

发布于 2024-07-29 23:58:46 字数 1473 浏览 2 评论 0原文

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

灯角 2024-08-05 23:58:46

该错误意味着编译器(解释器)遇到了在当前上下文中没有意义的符号。 使用标准样式 if 的地方是第 130 行,它使用大括号而不是 if 的替代形式。 因此,在第 130 行进行更改:

 if ($_SERVER['REQUEST_METHOD'] != 'POST'){

顺便

 if ($_SERVER['REQUEST_METHOD'] != 'POST') :

说一句,如果您感兴趣的话,神秘消息实际上来自 Bison。

还有一些其他翻转的标准 if 和 elseif。 这是编译良好的完整代码:

<!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">

<?php

//==============
//CONFIGURATION
//==============

//IMPORTANT!!
//Put in your email address below:
//$to = '[email protected]';
$to = '[email protected]';


//User info (DO NOT EDIT!)
$name = stripslashes($_POST['name']); //sender's name
$email = stripslashes($_POST['email']); //sender's email
$website = stripslashes($_POST['website']); //sender's website

//The subject
//$subject  = "[LightFormX Contact Form] "; //The default subject. Will appear by default in all messages. Change this if you want.
$subject .= stripslashes($_POST['subject']); // the subject


//The message you will receive in your mailbox
//Each parts are commented to help you understand what it does exaclty.
//YOU DON'T NEED TO EDIT IT BELOW BUT IF YOU DO, DO IT WITH CAUTION!
$msg  = "From : $name \r\n";  //add sender's name to the message
$msg .= "e-Mail : $email \r\n";  //add sender's email to the message
$msg .= "Website : $website \r\n"; //add sender's website to the message
$msg .= "Subject : $subject \r\n\n"; //add subject to the message (optional! It will be displayed in the header anyway)
$msg .= "---Message--- \r\n".stripslashes($_POST['message'])."\r\n\n";  //the message itself

?>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="Author" content="Merchant Monkland Associations" />
<meta name="copyright" content="Merchant Monkland Associations" />
<meta name="Description" content="The Monkland Merchant Association Contact form & Information " />
<meta name="Keywords" content="monkland village, monkland avenue,  montreal, NDG, restaurants, video store, shops,  mma, boutiques, mma media, SDC monkland, contact monkland" />
<title>The Monkland Merchant Association – Contact form & Information </title>
<link rel="stylesheet" href="style.css" type="text/css" media="screen" />

<script type="text/javascript" src="js/mootools.js"></script>

<!-- Formcheck2 / Moo.Floor.ch -->
<!-- http://moo.floor.ch/?p=18 -->
<script type="text/javascript" src="js/formcheck.js"></script>
<script type="text/javascript">
    window.addEvent('domready', function(){check = new FormCheck('third', {
        display : {
                fadeDuration : 500,
                errorsLocation : 1,
                indicateErrors : 1,
                showErrors : 1
        }
    })});
</script>

<!-- NiceForms / BadBoy.ro -->
<!-- http://www.badboy.ro/articles/2005-07-23/niceforms_preview/ -->
<script type="text/javascript" src="js/niceforms.js"></script>

</style>

</head>
<body id="Contact">
<!--START WRAPPER-->
<div id="wrapper">
<!--LOGO-->
<div id="logo"><a href="index.php"><img src="images/mma-logo.jpg" width="215" height="143" border="0" /></a></div>
<!--END LOGO-->
<?php 
if($lang=='en' || $lang==''):

include('include/Top_Menu.php');
endif; 

if($lang=='fr'):

include('include/Top_Menu-fr.php');
endif; 
?>
<!--MAIN MENU-->
<?php 
if($lang=='en' || $lang==''):

include('include/M_menu.php');
endif; 

if($lang=='fr'):

include('include/M_menu-fr.php');
endif; 
?>
<!--END MENU-->
<div id="contactBanner">
<?php //include ('include/MemberSubmenu.php');?>
</div>
<!--RIGHT BOX-->
<?php 
if($lang=='en' || $lang==''):

include('include/About-R_box.php');
endif; 

if($lang=='fr'):

include('include/About-R_box-fr.php');
endif; 
?>
<!--END RIGHT BOX-->
<?php if ($lang=='' || $lang=='en'): ?>

<div id="ContentBody">
<h2>Contact us</h2>
<p><h3 class="blue">Monkland Merchant Association</h3>
<a href="mailto:[email protected]">[email protected]</a><br />
514-658-8909</p>

<p><h3 class="blue">Mailing address:</h3>
1751 Richardson, #8.135<br />
Montreal, Quebec H3K 1G6 </p>

<h3 class="blue">Via E-mail:</h3>
<!-- The contact form starts here-->
<?php
   if ($_SERVER['REQUEST_METHOD'] != 'POST') :
      $self = $_SERVER['PHP_SELF'];
?>

    <!-- Start HTML form -->
    <form name="form" method="post" id="third" action="<?php echo $self;?>"  class="niceform">
        <!-- Name -->
        <label for="name"><strong><span class="blue">*</span> Name : </strong></label>
                <input id="name" name="name" type="text" class="validate['required','length[3,-1]','nodigit']" size="20" />

        <!-- Email -->
        <label for="email"><strong><span class="blue">*</span> Email : </strong></label>
                <input id="email" name="email" type="text" class="validate['required','length[5,-1]','email']" size="20" />

        <!-- Website -->
        <label for="site">Website : </label>
                <input id="website" name="website" type="text" class="validate['url']" size="20" />

        <!-- Subject -->
        <label for="subject"><strong><span class="blue">*</span> Subject : </strong></label>
                <input id="subject" name="subject" type="text" class="validate['required']" size="20" />

        <!-- Message -->
        <label for="msg"><strong><span class="blue">*</span> Your message : </strong></label><br />
                <textarea id="message" name="message" type="text" class="validate['required']" rows="10" cols="30"></textarea>

        <!-- Spam Check -->
        <label for="spamcheck"><span class="blue">*</span> <acronym  title="[ Spam prevention ]"><strong>Are you human?</strong></acronym> : <span class="blue"><strong>2 + 3 = ???</span></strong></label>
                <input id="spamcheck" name="spamcheck" type="text" size="5" class="validate['required','number','spamcheck']" />

        <br /><br />
        <input type="submit" class="buttonSubmit" value="Send it!" />

        <!-- Niceforms: mouse over effect -->
        <!-- Do not remove the line below -->
        <div id="stylesheetTest"></div>

    </form>

</div>


<?php endif; //end english 

/*  
*******************************************
**************** FRENCH ******************  
*******************************************
*/

 if($lang=='fr'): ?> 


<div id="ContentBody">
<h2>Pour nous joindre</h2>
<p><h3 class="blue">Association des marchands de la rue Monkland</h3>
<a href="mailto:[email protected]">[email protected]</a><br />
514-658-8909</p>

<p><h3 class="blue">Adresse postale :</h3>
1751, rue Richardson, bureau 8.135<br />
Montréal (Québec) H3K 1G6  </p>

<h3 class="blue">Via E-mail:</h3>
<!-- The contact form starts here-->
<?php
   if ($_SERVER['REQUEST_METHOD'] != 'POST'): 
      $self = $_SERVER['PHP_SELF'];
?>

    <!-- Start HTML form -->
    <form name="form" method="post" id="third" action="<?php echo $self;?>"  class="niceform">
        <!-- Name -->
        <label for="name"><strong><span class="blue">*</span> Nom  : </strong></label>
                <input id="name" name="name" type="text" class="validate['required','length[3,-1]','nodigit']" size="20" />

        <!-- Email -->
        <label for="email"><strong><span class="blue">*</span> Courriel  : </strong></label>
                <input id="email" name="email" type="text" class="validate['required','length[5,-1]','email']" size="20" />

        <!-- Website -->
        <label for="site">Site Web : </label>
                <input id="website" name="website" type="text" class="validate['url']" size="20" />

        <!-- Subject -->
        <label for="subject"><strong><span class="blue">*</span> Objet : </strong></label>
                <input id="subject" name="subject" type="text" class="validate['required']" size="20" />

        <!-- Message -->
        <label for="msg"><strong><span class="blue">*</span> Votre message : </strong></label><br />
                <textarea id="message" name="message" type="text" class="validate['required']" rows="10" cols="30"></textarea>

        <!-- Spam Check -->
        <label for="spamcheck"><span class="blue">*</span> <acronym  title="[ Spam prevention ]"><strong>Ëtes-vous un robot?</strong></acronym> : <span class="blue"><strong>2 + 3 = ???</span></strong></label>
                <input id="spamcheck" name="spamcheck" type="text" size="5" class="validate['required','number','spamcheck']" />

        <br /><br />
        <input type="submit" class="buttonSubmit" value="Envoyez!" />

        <!-- Niceforms: mouse over effect -->
        <!-- Do not remove the line below -->
        <div id="stylesheetTest"></div>

    </form>

</div>
<?php endif; // end french ?>

<?php 
if($lang=='en' || $lang==''):

echo ('<div class="clr"></div>
<div id="footerNav">
<a href="index.php">Home</a> | <a href="mission-mma.php">About us</a> | <a href="our-village-mma.php">Our village</a> | <a href="our-services-mma.php">Our services</a> | <a href="our-events-mma.php">Our events</a> | <a href="our-members-mma.php">Our members</a> | <a href="faq-mma.php">FAQ</a> | <a href="press-mma.php">Press</a> | <a href="contact-mma.php">Contact us</a><br />
Copyright Monkland Merchant Association - All rights managed<br />
<span>Website design by : Phil Communications - <a href="http://www.philcommunications.com" target="_blank">Non-profit spealists</a></span>
</div>
</div> ');
endif; 

if($lang=='fr'):

echo ('<div class="clr"></div>
<div id="footerNav">
<a href="index-fr.php?lang=fr">Accueil</a> | <a href="mission-mma.php?lang=fr">À propos</a> | <a href="our-village-mma.php?lang=fr">Notre village</a> | <a href="our-services-mma.php?lang=fr">Nos services</a> | <a href="our-events-mma.php?lang=fr">Nos évènements</a> | <a href="our-members-mma.php?lang=fr">Nos membres</a> | <a href="faq-mma.php?lang=fr">FAQ</a> | <a href="press-mma.php?lang=fr">Média</a> | <a href="contact-mma.php?lang=fr">Contact</a><br />
©  Association des marchands de la rue Monkland – Tous droits réservés<br />
<span>Site Web conçu par : Phil Communications -  <a href="http://www.philcommunications.com" target="_blank">Dévoué aux organismes communautaires et sociaux </a></span>
</div>
</div>');
endif; 
?>

<!-- / footer -->


<?php
    else:
        error_reporting(0);

        if  (mail($to, $subject, $msg, "From: $email\r\nReply-To: $email\r\nReturn-Path: $email\r\n"))

        //Message sent!
        //It the message that will be displayed when the user click the sumbit button
        //You can modify the text if you want
        echo nl2br("
        <div class=\"MsgSent\">
                <h1>Congratulations!!</h1>
                <p>Thank you <b>$name</b>, your message is sent!<br /> We will get back to you as soon as possible.</p>
        </div>
       ");

        else

        // Display error message if the message failed to send
        echo "
        <div class=\"MsgError\">
                <h1>Error!!</h1>
                <p>Sorry <b><?=$name;?></b>, your message failed to send. Try later!</p>
        </div>";

        endif;

    endif;

?>

</body>
</html>

The error means that the compiler (interpreter) has encountered a symbol that doesn't make sense in the current context. The one place where standard style if's are used is on line 130, where it is using braces instead of the alternate form of if. So, on line 130 change:

 if ($_SERVER['REQUEST_METHOD'] != 'POST'){

to

 if ($_SERVER['REQUEST_METHOD'] != 'POST') :

BTW the cryptic message actually comes from Bison, if you are interested.

There are a couple of other flipped standard if's and elseifs. Here is the complete code that compiles fine:

<!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">

<?php

//==============
//CONFIGURATION
//==============

//IMPORTANT!!
//Put in your email address below:
//$to = '[email protected]';
$to = '[email protected]';


//User info (DO NOT EDIT!)
$name = stripslashes($_POST['name']); //sender's name
$email = stripslashes($_POST['email']); //sender's email
$website = stripslashes($_POST['website']); //sender's website

//The subject
//$subject  = "[LightFormX Contact Form] "; //The default subject. Will appear by default in all messages. Change this if you want.
$subject .= stripslashes($_POST['subject']); // the subject


//The message you will receive in your mailbox
//Each parts are commented to help you understand what it does exaclty.
//YOU DON'T NEED TO EDIT IT BELOW BUT IF YOU DO, DO IT WITH CAUTION!
$msg  = "From : $name \r\n";  //add sender's name to the message
$msg .= "e-Mail : $email \r\n";  //add sender's email to the message
$msg .= "Website : $website \r\n"; //add sender's website to the message
$msg .= "Subject : $subject \r\n\n"; //add subject to the message (optional! It will be displayed in the header anyway)
$msg .= "---Message--- \r\n".stripslashes($_POST['message'])."\r\n\n";  //the message itself

?>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="Author" content="Merchant Monkland Associations" />
<meta name="copyright" content="Merchant Monkland Associations" />
<meta name="Description" content="The Monkland Merchant Association Contact form & Information " />
<meta name="Keywords" content="monkland village, monkland avenue,  montreal, NDG, restaurants, video store, shops,  mma, boutiques, mma media, SDC monkland, contact monkland" />
<title>The Monkland Merchant Association – Contact form & Information </title>
<link rel="stylesheet" href="style.css" type="text/css" media="screen" />

<script type="text/javascript" src="js/mootools.js"></script>

<!-- Formcheck2 / Moo.Floor.ch -->
<!-- http://moo.floor.ch/?p=18 -->
<script type="text/javascript" src="js/formcheck.js"></script>
<script type="text/javascript">
    window.addEvent('domready', function(){check = new FormCheck('third', {
        display : {
                fadeDuration : 500,
                errorsLocation : 1,
                indicateErrors : 1,
                showErrors : 1
        }
    })});
</script>

<!-- NiceForms / BadBoy.ro -->
<!-- http://www.badboy.ro/articles/2005-07-23/niceforms_preview/ -->
<script type="text/javascript" src="js/niceforms.js"></script>

</style>

</head>
<body id="Contact">
<!--START WRAPPER-->
<div id="wrapper">
<!--LOGO-->
<div id="logo"><a href="index.php"><img src="images/mma-logo.jpg" width="215" height="143" border="0" /></a></div>
<!--END LOGO-->
<?php 
if($lang=='en' || $lang==''):

include('include/Top_Menu.php');
endif; 

if($lang=='fr'):

include('include/Top_Menu-fr.php');
endif; 
?>
<!--MAIN MENU-->
<?php 
if($lang=='en' || $lang==''):

include('include/M_menu.php');
endif; 

if($lang=='fr'):

include('include/M_menu-fr.php');
endif; 
?>
<!--END MENU-->
<div id="contactBanner">
<?php //include ('include/MemberSubmenu.php');?>
</div>
<!--RIGHT BOX-->
<?php 
if($lang=='en' || $lang==''):

include('include/About-R_box.php');
endif; 

if($lang=='fr'):

include('include/About-R_box-fr.php');
endif; 
?>
<!--END RIGHT BOX-->
<?php if ($lang=='' || $lang=='en'): ?>

<div id="ContentBody">
<h2>Contact us</h2>
<p><h3 class="blue">Monkland Merchant Association</h3>
<a href="mailto:[email protected]">[email protected]</a><br />
514-658-8909</p>

<p><h3 class="blue">Mailing address:</h3>
1751 Richardson, #8.135<br />
Montreal, Quebec H3K 1G6 </p>

<h3 class="blue">Via E-mail:</h3>
<!-- The contact form starts here-->
<?php
   if ($_SERVER['REQUEST_METHOD'] != 'POST') :
      $self = $_SERVER['PHP_SELF'];
?>

    <!-- Start HTML form -->
    <form name="form" method="post" id="third" action="<?php echo $self;?>"  class="niceform">
        <!-- Name -->
        <label for="name"><strong><span class="blue">*</span> Name : </strong></label>
                <input id="name" name="name" type="text" class="validate['required','length[3,-1]','nodigit']" size="20" />

        <!-- Email -->
        <label for="email"><strong><span class="blue">*</span> Email : </strong></label>
                <input id="email" name="email" type="text" class="validate['required','length[5,-1]','email']" size="20" />

        <!-- Website -->
        <label for="site">Website : </label>
                <input id="website" name="website" type="text" class="validate['url']" size="20" />

        <!-- Subject -->
        <label for="subject"><strong><span class="blue">*</span> Subject : </strong></label>
                <input id="subject" name="subject" type="text" class="validate['required']" size="20" />

        <!-- Message -->
        <label for="msg"><strong><span class="blue">*</span> Your message : </strong></label><br />
                <textarea id="message" name="message" type="text" class="validate['required']" rows="10" cols="30"></textarea>

        <!-- Spam Check -->
        <label for="spamcheck"><span class="blue">*</span> <acronym  title="[ Spam prevention ]"><strong>Are you human?</strong></acronym> : <span class="blue"><strong>2 + 3 = ???</span></strong></label>
                <input id="spamcheck" name="spamcheck" type="text" size="5" class="validate['required','number','spamcheck']" />

        <br /><br />
        <input type="submit" class="buttonSubmit" value="Send it!" />

        <!-- Niceforms: mouse over effect -->
        <!-- Do not remove the line below -->
        <div id="stylesheetTest"></div>

    </form>

</div>


<?php endif; //end english 

/*  
*******************************************
**************** FRENCH ******************  
*******************************************
*/

 if($lang=='fr'): ?> 


<div id="ContentBody">
<h2>Pour nous joindre</h2>
<p><h3 class="blue">Association des marchands de la rue Monkland</h3>
<a href="mailto:[email protected]">[email protected]</a><br />
514-658-8909</p>

<p><h3 class="blue">Adresse postale :</h3>
1751, rue Richardson, bureau 8.135<br />
Montréal (Québec) H3K 1G6  </p>

<h3 class="blue">Via E-mail:</h3>
<!-- The contact form starts here-->
<?php
   if ($_SERVER['REQUEST_METHOD'] != 'POST'): 
      $self = $_SERVER['PHP_SELF'];
?>

    <!-- Start HTML form -->
    <form name="form" method="post" id="third" action="<?php echo $self;?>"  class="niceform">
        <!-- Name -->
        <label for="name"><strong><span class="blue">*</span> Nom  : </strong></label>
                <input id="name" name="name" type="text" class="validate['required','length[3,-1]','nodigit']" size="20" />

        <!-- Email -->
        <label for="email"><strong><span class="blue">*</span> Courriel  : </strong></label>
                <input id="email" name="email" type="text" class="validate['required','length[5,-1]','email']" size="20" />

        <!-- Website -->
        <label for="site">Site Web : </label>
                <input id="website" name="website" type="text" class="validate['url']" size="20" />

        <!-- Subject -->
        <label for="subject"><strong><span class="blue">*</span> Objet : </strong></label>
                <input id="subject" name="subject" type="text" class="validate['required']" size="20" />

        <!-- Message -->
        <label for="msg"><strong><span class="blue">*</span> Votre message : </strong></label><br />
                <textarea id="message" name="message" type="text" class="validate['required']" rows="10" cols="30"></textarea>

        <!-- Spam Check -->
        <label for="spamcheck"><span class="blue">*</span> <acronym  title="[ Spam prevention ]"><strong>Ëtes-vous un robot?</strong></acronym> : <span class="blue"><strong>2 + 3 = ???</span></strong></label>
                <input id="spamcheck" name="spamcheck" type="text" size="5" class="validate['required','number','spamcheck']" />

        <br /><br />
        <input type="submit" class="buttonSubmit" value="Envoyez!" />

        <!-- Niceforms: mouse over effect -->
        <!-- Do not remove the line below -->
        <div id="stylesheetTest"></div>

    </form>

</div>
<?php endif; // end french ?>

<?php 
if($lang=='en' || $lang==''):

echo ('<div class="clr"></div>
<div id="footerNav">
<a href="index.php">Home</a> | <a href="mission-mma.php">About us</a> | <a href="our-village-mma.php">Our village</a> | <a href="our-services-mma.php">Our services</a> | <a href="our-events-mma.php">Our events</a> | <a href="our-members-mma.php">Our members</a> | <a href="faq-mma.php">FAQ</a> | <a href="press-mma.php">Press</a> | <a href="contact-mma.php">Contact us</a><br />
Copyright Monkland Merchant Association - All rights managed<br />
<span>Website design by : Phil Communications - <a href="http://www.philcommunications.com" target="_blank">Non-profit spealists</a></span>
</div>
</div> ');
endif; 

if($lang=='fr'):

echo ('<div class="clr"></div>
<div id="footerNav">
<a href="index-fr.php?lang=fr">Accueil</a> | <a href="mission-mma.php?lang=fr">À propos</a> | <a href="our-village-mma.php?lang=fr">Notre village</a> | <a href="our-services-mma.php?lang=fr">Nos services</a> | <a href="our-events-mma.php?lang=fr">Nos évènements</a> | <a href="our-members-mma.php?lang=fr">Nos membres</a> | <a href="faq-mma.php?lang=fr">FAQ</a> | <a href="press-mma.php?lang=fr">Média</a> | <a href="contact-mma.php?lang=fr">Contact</a><br />
©  Association des marchands de la rue Monkland – Tous droits réservés<br />
<span>Site Web conçu par : Phil Communications -  <a href="http://www.philcommunications.com" target="_blank">Dévoué aux organismes communautaires et sociaux </a></span>
</div>
</div>');
endif; 
?>

<!-- / footer -->


<?php
    else:
        error_reporting(0);

        if  (mail($to, $subject, $msg, "From: $email\r\nReply-To: $email\r\nReturn-Path: $email\r\n"))

        //Message sent!
        //It the message that will be displayed when the user click the sumbit button
        //You can modify the text if you want
        echo nl2br("
        <div class=\"MsgSent\">
                <h1>Congratulations!!</h1>
                <p>Thank you <b>$name</b>, your message is sent!<br /> We will get back to you as soon as possible.</p>
        </div>
       ");

        else

        // Display error message if the message failed to send
        echo "
        <div class=\"MsgError\">
                <h1>Error!!</h1>
                <p>Sorry <b><?=$name;?></b>, your message failed to send. Try later!</p>
        </div>";

        endif;

    endif;

?>

</body>
</html>
怪我入戏太深 2024-08-05 23:58:46

尝试替换

<?php endif; //end english

<?php }; //end english

try replacing

<?php endif; //end english

with

<?php }; //end english
记忆之渊 2024-08-05 23:58:46

你必须替换

<?php
   if ($_SERVER['REQUEST_METHOD'] != 'POST'){

<?php
   if ($_SERVER['REQUEST_METHOD'] != 'POST'):

you have to replace

<?php
   if ($_SERVER['REQUEST_METHOD'] != 'POST'){

with

<?php
   if ($_SERVER['REQUEST_METHOD'] != 'POST'):
南街九尾狐 2024-08-05 23:58:46

您需要先输入 } 来结束 if ($_SERVER['REQUEST_METHOD'] != 'POST'){,然后才能结束英文 if

所以像这样:

<!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">

<?php

//==============
//CONFIGURATION
//==============

//IMPORTANT!!
//Put in your email address below:
//$to = '[email protected]';
$to = '[email protected]';


//User info (DO NOT EDIT!)
$name = stripslashes($_POST['name']); //sender's name
$email = stripslashes($_POST['email']); //sender's email
$website = stripslashes($_POST['website']); //sender's website

//The subject
//$subject  = "[LightFormX Contact Form] "; //The default subject. Will appear by default in all messages. Change this if you want.
$subject .= stripslashes($_POST['subject']); // the subject


//The message you will receive in your mailbox
//Each parts are commented to help you understand what it does exaclty.
//YOU DON'T NEED TO EDIT IT BELOW BUT IF YOU DO, DO IT WITH CAUTION!
$msg  = "From : $name \r\n";  //add sender's name to the message
$msg .= "e-Mail : $email \r\n";  //add sender's email to the message
$msg .= "Website : $website \r\n"; //add sender's website to the message
$msg .= "Subject : $subject \r\n\n"; //add subject to the message (optional! It will be displayed in the header anyway)
$msg .= "---Message--- \r\n".stripslashes($_POST['message'])."\r\n\n";  //the message itself

?>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="Author" content="Merchant Monkland Associations" />
<meta name="copyright" content="Merchant Monkland Associations" />
<meta name="Description" content="The Monkland Merchant Association Contact form & Information " />
<meta name="Keywords" content="monkland village, monkland avenue,  montreal, NDG, restaurants, video store, shops,  mma, boutiques, mma media, SDC monkland, contact monkland" />
<title>The Monkland Merchant Association – Contact form & Information </title>
<link rel="stylesheet" href="style.css" type="text/css" media="screen" />

<script type="text/javascript" src="js/mootools.js"></script>

<!-- Formcheck2 / Moo.Floor.ch -->
<!-- http://moo.floor.ch/?p=18 -->
<script type="text/javascript" src="js/formcheck.js"></script>
<script type="text/javascript">
    window.addEvent('domready', function(){check = new FormCheck('third', {
        display : {
                fadeDuration : 500,
                errorsLocation : 1,
                indicateErrors : 1,
                showErrors : 1
        }
    })});
</script>

<!-- NiceForms / BadBoy.ro -->
<!-- http://www.badboy.ro/articles/2005-07-23/niceforms_preview/ -->
<script type="text/javascript" src="js/niceforms.js"></script>

</style>

</head>
<body id="Contact">
<!--START WRAPPER-->
<div id="wrapper">
<!--LOGO-->
<div id="logo"><a href="index.php"><img src="images/mma-logo.jpg" width="215" height="143" border="0" /></a></div>
<!--END LOGO-->
<?php 
if($lang=='en' || $lang==''):

include('include/Top_Menu.php');
endif; 

if($lang=='fr'):

include('include/Top_Menu-fr.php');
endif; 
?>
<!--MAIN MENU-->
<?php 
if($lang=='en' || $lang==''):

include('include/M_menu.php');
endif; 

if($lang=='fr'):

include('include/M_menu-fr.php');
endif; 
?>
<!--END MENU-->
<div id="contactBanner">
<?php //include ('include/MemberSubmenu.php');?>
</div>
<!--RIGHT BOX-->
<?php 
if($lang=='en' || $lang==''):

include('include/About-R_box.php');
endif; 

if($lang=='fr'):

include('include/About-R_box-fr.php');
endif; 
?>
<!--END RIGHT BOX-->
<?php if ($lang=='' || $lang=='en'): ?>

<div id="ContentBody">
<h2>Contact us</h2>
<p><h3 class="blue">Monkland Merchant Association</h3>
<a href="mailto:[email protected]">[email protected]</a><br />
514-658-8909</p>

<p><h3 class="blue">Mailing address:</h3>
1751 Richardson, #8.135<br />
Montreal, Quebec H3K 1G6 </p>

<h3 class="blue">Via E-mail:</h3>
<!-- The contact form starts here-->
<?php
   if ($_SERVER['REQUEST_METHOD'] != 'POST'){
      $self = $_SERVER['PHP_SELF'];
?>

    <!-- Start HTML form -->
    <form name="form" method="post" id="third" action="<?php echo $self;?>"  class="niceform">
        <!-- Name -->
        <label for="name"><strong><span class="blue">*</span> Name : </strong></label>
                <input id="name" name="name" type="text" class="validate['required','length[3,-1]','nodigit']" size="20" />

        <!-- Email -->
        <label for="email"><strong><span class="blue">*</span> Email : </strong></label>
                <input id="email" name="email" type="text" class="validate['required','length[5,-1]','email']" size="20" />

        <!-- Website -->
        <label for="site">Website : </label>
                <input id="website" name="website" type="text" class="validate['url']" size="20" />

        <!-- Subject -->
        <label for="subject"><strong><span class="blue">*</span> Subject : </strong></label>
                <input id="subject" name="subject" type="text" class="validate['required']" size="20" />

        <!-- Message -->
        <label for="msg"><strong><span class="blue">*</span> Your message : </strong></label><br />
                <textarea id="message" name="message" type="text" class="validate['required']" rows="10" cols="30"></textarea>

        <!-- Spam Check -->
        <label for="spamcheck"><span class="blue">*</span> <acronym  title="[ Spam prevention ]"><strong>Are you human?</strong></acronym> : <span class="blue"><strong>2 + 3 = ???</span></strong></label>
                <input id="spamcheck" name="spamcheck" type="text" size="5" class="validate['required','number','spamcheck']" />

        <br /><br />
        <input type="submit" class="buttonSubmit" value="Send it!" />

        <!-- Niceforms: mouse over effect -->
        <!-- Do not remove the line below -->
        <div id="stylesheetTest"></div>

    </form>

</div>


<?php endif; //end english 

/*  
*******************************************
**************** FRENCH ******************  
*******************************************
*/

 if($lang=='fr'): ?> 


<div id="ContentBody">
<h2>Pour nous joindre</h2>
<p><h3 class="blue">Association des marchands de la rue Monkland</h3>
<a href="mailto:[email protected]">[email protected]</a><br />
514-658-8909</p>

<p><h3 class="blue">Adresse postale :</h3>
1751, rue Richardson, bureau 8.135<br />
Montréal (Québec) H3K 1G6  </p>

<h3 class="blue">Via E-mail:</h3>
<!-- The contact form starts here-->
<?php
   if ($_SERVER['REQUEST_METHOD'] != 'POST'){
      $self = $_SERVER['PHP_SELF'];
?>

    <!-- Start HTML form -->
    <form name="form" method="post" id="third" action="<?php echo $self;?>"  class="niceform">
        <!-- Name -->
        <label for="name"><strong><span class="blue">*</span> Nom  : </strong></label>
                <input id="name" name="name" type="text" class="validate['required','length[3,-1]','nodigit']" size="20" />

        <!-- Email -->
        <label for="email"><strong><span class="blue">*</span> Courriel  : </strong></label>
                <input id="email" name="email" type="text" class="validate['required','length[5,-1]','email']" size="20" />

        <!-- Website -->
        <label for="site">Site Web : </label>
                <input id="website" name="website" type="text" class="validate['url']" size="20" />

        <!-- Subject -->
        <label for="subject"><strong><span class="blue">*</span> Objet : </strong></label>
                <input id="subject" name="subject" type="text" class="validate['required']" size="20" />

        <!-- Message -->
        <label for="msg"><strong><span class="blue">*</span> Votre message : </strong></label><br />
                <textarea id="message" name="message" type="text" class="validate['required']" rows="10" cols="30"></textarea>

        <!-- Spam Check -->
        <label for="spamcheck"><span class="blue">*</span> <acronym  title="[ Spam prevention ]"><strong>Ëtes-vous un robot?</strong></acronym> : <span class="blue"><strong>2 + 3 = ???</span></strong></label>
                <input id="spamcheck" name="spamcheck" type="text" size="5" class="validate['required','number','spamcheck']" />

        <br /><br />
        <input type="submit" class="buttonSubmit" value="Envoyez!" />

        <!-- Niceforms: mouse over effect -->
        <!-- Do not remove the line below -->
        <div id="stylesheetTest"></div>

    </form>

</div>
<?php }
endif; // end french ?>

<?php 
if($lang=='en' || $lang==''):

echo ('<div class="clr"></div>
<div id="footerNav">
<a href="index.php">Home</a> | <a href="mission-mma.php">About us</a> | <a href="our-village-mma.php">Our village</a> | <a href="our-services-mma.php">Our services</a> | <a href="our-events-mma.php">Our events</a> | <a href="our-members-mma.php">Our members</a> | <a href="faq-mma.php">FAQ</a> | <a href="press-mma.php">Press</a> | <a href="contact-mma.php">Contact us</a><br />
Copyright Monkland Merchant Association - All rights managed<br />
<span>Website design by : Phil Communications - <a href="http://www.philcommunications.com" target="_blank">Non-profit spealists</a></span>
</div>
</div> ');
endif; 

if($lang=='fr'):

echo ('<div class="clr"></div>
<div id="footerNav">
<a href="index-fr.php?lang=fr">Accueil</a> | <a href="mission-mma.php?lang=fr">À propos</a> | <a href="our-village-mma.php?lang=fr">Notre village</a> | <a href="our-services-mma.php?lang=fr">Nos services</a> | <a href="our-events-mma.php?lang=fr">Nos évènements</a> | <a href="our-members-mma.php?lang=fr">Nos membres</a> | <a href="faq-mma.php?lang=fr">FAQ</a> | <a href="press-mma.php?lang=fr">Média</a> | <a href="contact-mma.php?lang=fr">Contact</a><br />
©  Association des marchands de la rue Monkland – Tous droits réservés<br />
<span>Site Web conçu par : Phil Communications -  <a href="http://www.philcommunications.com" target="_blank">Dévoué aux organismes communautaires et sociaux </a></span>
</div>
</div>');
endif; 
?>

<!-- / footer -->


<?php
    } else {
        error_reporting(0);

        if  (mail($to, $subject, $msg, "From: $email\r\nReply-To: $email\r\nReturn-Path: $email\r\n"))

        //Message sent!
        //It the message that will be displayed when the user click the sumbit button
        //You can modify the text if you want
        echo nl2br("
        <div class=\"MsgSent\">
                <h1>Congratulations!!</h1>
                <p>Thank you <b>$name</b>, your message is sent!<br /> We will get back to you as soon as possible.</p>
        </div>
       ");

        else

        // Display error message if the message failed to send
        echo "
        <div class=\"MsgError\">
                <h1>Error!!</h1>
                <p>Sorry <b><?=$name;?></b>, your message failed to send. Try later!</p>
        </div>";
    }
?>

</body>
</html>

因为 if 语句是嵌套的,所以它想要结束最近打开的 if 语句,因此它需要一个右括号,因为这就是您打开的方式。 当它看到 endif 时,它会说“这不是最近的 if 使用的内容”,并出现错误。

You need to put in a } to end the if ($_SERVER['REQUEST_METHOD'] != 'POST'){ before you can end the english if

So something like this:

<!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">

<?php

//==============
//CONFIGURATION
//==============

//IMPORTANT!!
//Put in your email address below:
//$to = '[email protected]';
$to = '[email protected]';


//User info (DO NOT EDIT!)
$name = stripslashes($_POST['name']); //sender's name
$email = stripslashes($_POST['email']); //sender's email
$website = stripslashes($_POST['website']); //sender's website

//The subject
//$subject  = "[LightFormX Contact Form] "; //The default subject. Will appear by default in all messages. Change this if you want.
$subject .= stripslashes($_POST['subject']); // the subject


//The message you will receive in your mailbox
//Each parts are commented to help you understand what it does exaclty.
//YOU DON'T NEED TO EDIT IT BELOW BUT IF YOU DO, DO IT WITH CAUTION!
$msg  = "From : $name \r\n";  //add sender's name to the message
$msg .= "e-Mail : $email \r\n";  //add sender's email to the message
$msg .= "Website : $website \r\n"; //add sender's website to the message
$msg .= "Subject : $subject \r\n\n"; //add subject to the message (optional! It will be displayed in the header anyway)
$msg .= "---Message--- \r\n".stripslashes($_POST['message'])."\r\n\n";  //the message itself

?>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="Author" content="Merchant Monkland Associations" />
<meta name="copyright" content="Merchant Monkland Associations" />
<meta name="Description" content="The Monkland Merchant Association Contact form & Information " />
<meta name="Keywords" content="monkland village, monkland avenue,  montreal, NDG, restaurants, video store, shops,  mma, boutiques, mma media, SDC monkland, contact monkland" />
<title>The Monkland Merchant Association – Contact form & Information </title>
<link rel="stylesheet" href="style.css" type="text/css" media="screen" />

<script type="text/javascript" src="js/mootools.js"></script>

<!-- Formcheck2 / Moo.Floor.ch -->
<!-- http://moo.floor.ch/?p=18 -->
<script type="text/javascript" src="js/formcheck.js"></script>
<script type="text/javascript">
    window.addEvent('domready', function(){check = new FormCheck('third', {
        display : {
                fadeDuration : 500,
                errorsLocation : 1,
                indicateErrors : 1,
                showErrors : 1
        }
    })});
</script>

<!-- NiceForms / BadBoy.ro -->
<!-- http://www.badboy.ro/articles/2005-07-23/niceforms_preview/ -->
<script type="text/javascript" src="js/niceforms.js"></script>

</style>

</head>
<body id="Contact">
<!--START WRAPPER-->
<div id="wrapper">
<!--LOGO-->
<div id="logo"><a href="index.php"><img src="images/mma-logo.jpg" width="215" height="143" border="0" /></a></div>
<!--END LOGO-->
<?php 
if($lang=='en' || $lang==''):

include('include/Top_Menu.php');
endif; 

if($lang=='fr'):

include('include/Top_Menu-fr.php');
endif; 
?>
<!--MAIN MENU-->
<?php 
if($lang=='en' || $lang==''):

include('include/M_menu.php');
endif; 

if($lang=='fr'):

include('include/M_menu-fr.php');
endif; 
?>
<!--END MENU-->
<div id="contactBanner">
<?php //include ('include/MemberSubmenu.php');?>
</div>
<!--RIGHT BOX-->
<?php 
if($lang=='en' || $lang==''):

include('include/About-R_box.php');
endif; 

if($lang=='fr'):

include('include/About-R_box-fr.php');
endif; 
?>
<!--END RIGHT BOX-->
<?php if ($lang=='' || $lang=='en'): ?>

<div id="ContentBody">
<h2>Contact us</h2>
<p><h3 class="blue">Monkland Merchant Association</h3>
<a href="mailto:[email protected]">[email protected]</a><br />
514-658-8909</p>

<p><h3 class="blue">Mailing address:</h3>
1751 Richardson, #8.135<br />
Montreal, Quebec H3K 1G6 </p>

<h3 class="blue">Via E-mail:</h3>
<!-- The contact form starts here-->
<?php
   if ($_SERVER['REQUEST_METHOD'] != 'POST'){
      $self = $_SERVER['PHP_SELF'];
?>

    <!-- Start HTML form -->
    <form name="form" method="post" id="third" action="<?php echo $self;?>"  class="niceform">
        <!-- Name -->
        <label for="name"><strong><span class="blue">*</span> Name : </strong></label>
                <input id="name" name="name" type="text" class="validate['required','length[3,-1]','nodigit']" size="20" />

        <!-- Email -->
        <label for="email"><strong><span class="blue">*</span> Email : </strong></label>
                <input id="email" name="email" type="text" class="validate['required','length[5,-1]','email']" size="20" />

        <!-- Website -->
        <label for="site">Website : </label>
                <input id="website" name="website" type="text" class="validate['url']" size="20" />

        <!-- Subject -->
        <label for="subject"><strong><span class="blue">*</span> Subject : </strong></label>
                <input id="subject" name="subject" type="text" class="validate['required']" size="20" />

        <!-- Message -->
        <label for="msg"><strong><span class="blue">*</span> Your message : </strong></label><br />
                <textarea id="message" name="message" type="text" class="validate['required']" rows="10" cols="30"></textarea>

        <!-- Spam Check -->
        <label for="spamcheck"><span class="blue">*</span> <acronym  title="[ Spam prevention ]"><strong>Are you human?</strong></acronym> : <span class="blue"><strong>2 + 3 = ???</span></strong></label>
                <input id="spamcheck" name="spamcheck" type="text" size="5" class="validate['required','number','spamcheck']" />

        <br /><br />
        <input type="submit" class="buttonSubmit" value="Send it!" />

        <!-- Niceforms: mouse over effect -->
        <!-- Do not remove the line below -->
        <div id="stylesheetTest"></div>

    </form>

</div>


<?php endif; //end english 

/*  
*******************************************
**************** FRENCH ******************  
*******************************************
*/

 if($lang=='fr'): ?> 


<div id="ContentBody">
<h2>Pour nous joindre</h2>
<p><h3 class="blue">Association des marchands de la rue Monkland</h3>
<a href="mailto:[email protected]">[email protected]</a><br />
514-658-8909</p>

<p><h3 class="blue">Adresse postale :</h3>
1751, rue Richardson, bureau 8.135<br />
Montréal (Québec) H3K 1G6  </p>

<h3 class="blue">Via E-mail:</h3>
<!-- The contact form starts here-->
<?php
   if ($_SERVER['REQUEST_METHOD'] != 'POST'){
      $self = $_SERVER['PHP_SELF'];
?>

    <!-- Start HTML form -->
    <form name="form" method="post" id="third" action="<?php echo $self;?>"  class="niceform">
        <!-- Name -->
        <label for="name"><strong><span class="blue">*</span> Nom  : </strong></label>
                <input id="name" name="name" type="text" class="validate['required','length[3,-1]','nodigit']" size="20" />

        <!-- Email -->
        <label for="email"><strong><span class="blue">*</span> Courriel  : </strong></label>
                <input id="email" name="email" type="text" class="validate['required','length[5,-1]','email']" size="20" />

        <!-- Website -->
        <label for="site">Site Web : </label>
                <input id="website" name="website" type="text" class="validate['url']" size="20" />

        <!-- Subject -->
        <label for="subject"><strong><span class="blue">*</span> Objet : </strong></label>
                <input id="subject" name="subject" type="text" class="validate['required']" size="20" />

        <!-- Message -->
        <label for="msg"><strong><span class="blue">*</span> Votre message : </strong></label><br />
                <textarea id="message" name="message" type="text" class="validate['required']" rows="10" cols="30"></textarea>

        <!-- Spam Check -->
        <label for="spamcheck"><span class="blue">*</span> <acronym  title="[ Spam prevention ]"><strong>Ëtes-vous un robot?</strong></acronym> : <span class="blue"><strong>2 + 3 = ???</span></strong></label>
                <input id="spamcheck" name="spamcheck" type="text" size="5" class="validate['required','number','spamcheck']" />

        <br /><br />
        <input type="submit" class="buttonSubmit" value="Envoyez!" />

        <!-- Niceforms: mouse over effect -->
        <!-- Do not remove the line below -->
        <div id="stylesheetTest"></div>

    </form>

</div>
<?php }
endif; // end french ?>

<?php 
if($lang=='en' || $lang==''):

echo ('<div class="clr"></div>
<div id="footerNav">
<a href="index.php">Home</a> | <a href="mission-mma.php">About us</a> | <a href="our-village-mma.php">Our village</a> | <a href="our-services-mma.php">Our services</a> | <a href="our-events-mma.php">Our events</a> | <a href="our-members-mma.php">Our members</a> | <a href="faq-mma.php">FAQ</a> | <a href="press-mma.php">Press</a> | <a href="contact-mma.php">Contact us</a><br />
Copyright Monkland Merchant Association - All rights managed<br />
<span>Website design by : Phil Communications - <a href="http://www.philcommunications.com" target="_blank">Non-profit spealists</a></span>
</div>
</div> ');
endif; 

if($lang=='fr'):

echo ('<div class="clr"></div>
<div id="footerNav">
<a href="index-fr.php?lang=fr">Accueil</a> | <a href="mission-mma.php?lang=fr">À propos</a> | <a href="our-village-mma.php?lang=fr">Notre village</a> | <a href="our-services-mma.php?lang=fr">Nos services</a> | <a href="our-events-mma.php?lang=fr">Nos évènements</a> | <a href="our-members-mma.php?lang=fr">Nos membres</a> | <a href="faq-mma.php?lang=fr">FAQ</a> | <a href="press-mma.php?lang=fr">Média</a> | <a href="contact-mma.php?lang=fr">Contact</a><br />
©  Association des marchands de la rue Monkland – Tous droits réservés<br />
<span>Site Web conçu par : Phil Communications -  <a href="http://www.philcommunications.com" target="_blank">Dévoué aux organismes communautaires et sociaux </a></span>
</div>
</div>');
endif; 
?>

<!-- / footer -->


<?php
    } else {
        error_reporting(0);

        if  (mail($to, $subject, $msg, "From: $email\r\nReply-To: $email\r\nReturn-Path: $email\r\n"))

        //Message sent!
        //It the message that will be displayed when the user click the sumbit button
        //You can modify the text if you want
        echo nl2br("
        <div class=\"MsgSent\">
                <h1>Congratulations!!</h1>
                <p>Thank you <b>$name</b>, your message is sent!<br /> We will get back to you as soon as possible.</p>
        </div>
       ");

        else

        // Display error message if the message failed to send
        echo "
        <div class=\"MsgError\">
                <h1>Error!!</h1>
                <p>Sorry <b><?=$name;?></b>, your message failed to send. Try later!</p>
        </div>";
    }
?>

</body>
</html>

Because the if statement is nested, it wants to end the most recently opened if statement, so it is expecting a close bracket because that is how you opened. When it sees the endif, it says "Thats not what the most recent if uses", and errors.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文