views:

109

answers:

4

I need help debugging

sample site : http://www.testground.idghosting.com/mma/contact-mma.php

in english it's shows the "sent message" even if the form is not filled.. but in french (top right corner link) it doesn' show the fomr at all....

Here is my whole code :

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
<html xmlns="http://www.w3.org/1999/xhtml"&gt;

<?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 href="<?php 
if($lang=='en' || $lang==''):

echo('style.css');
endif; 

if($lang=='fr'):

echo('style-fr.css');
endif; 
?>" rel="stylesheet" type="text/css" media="all" />

<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="<?php 
if($lang=='en' || $lang==''):

echo('images/mma-logo.jpg');
endif; 

if($lang=='fr'):

echo('images/mma-logo-fr.jpg');
endif; 
?>" 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">&Agrave; 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 &eacute;v&egrave;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&eacute;dia</a> | <a href="contact-mma.php?lang=fr">Contact</a><br />
&copy;  Association des marchands de la rue Monkland &ndash; Tous droits r&eacute;serv&eacute;s<br />
<span>Site Web con&ccedil;u par : Phil Communications -  <a href="http://www.philcommunications.com" target="_blank">D&eacute;vou&eacute; 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>
A: 

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"&gt;
<html xmlns="http://www.w3.org/1999/xhtml"&gt;

<?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">&Agrave; 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 &eacute;v&egrave;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&eacute;dia</a> | <a href="contact-mma.php?lang=fr">Contact</a><br />
&copy;  Association des marchands de la rue Monkland &ndash; Tous droits r&eacute;serv&eacute;s<br />
<span>Site Web con&ccedil;u par : Phil Communications -  <a href="http://www.philcommunications.com" target="_blank">D&eacute;vou&eacute; 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.

Chacha102
did know i got the error "Parse error: syntax error, unexpected '}' in /home/idghosti/public_html/testground/mma/contact-mma.php on line 268"
kwek-kwek
The same thing happened in the french version.
Chacha102
So you need to fix both language versions with adding a `}`
Chacha102
i did it both languages but still error "Parse error: syntax error, unexpected '}' in /home/idghosti/public_html/testground/mma/contact-mma.php on line 172"
kwek-kwek
Can you update your post with your most recent code?
Chacha102
I just updated my post with the full code. That should work.
Chacha102
I have updated my post it worked but it's showing weird glitches on the english side but on the french it doesn't show the form at all.....
kwek-kwek
What kind of glitches?
Chacha102
A: 

try replacing

<?php endif; //end english

with

<?php }; //end english
Glass Robot
Is good enough too, why the negative?
inakiabt
If he did this, the english `if` would overlap with the french one, causing glitches
Chacha102
+1  A: 

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"&gt;
<html xmlns="http://www.w3.org/1999/xhtml"&gt;

<?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">&Agrave; 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 &eacute;v&egrave;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&eacute;dia</a> | <a href="contact-mma.php?lang=fr">Contact</a><br />
&copy;  Association des marchands de la rue Monkland &ndash; Tous droits r&eacute;serv&eacute;s<br />
<span>Site Web con&ccedil;u par : Phil Communications -  <a href="http://www.philcommunications.com" target="_blank">D&eacute;vou&eacute; 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>
Kris Erickson
this work but my form in french doesn't show up....
kwek-kwek
I just checked it for syntax, not logic. The problem with alternate form if's is that it makes it very hard to determine logic, especially with the lack of indenting. Perhaps if you switch to standard style if's then you can figure why this is failing.
Kris Erickson
I have updated my post....... please help....
kwek-kwek
A: 

you have to replace

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

with

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