We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
  • Quote from: bugsmi0 at Jul 25, 2006, 07:24 AM

    parse error says syntax error unexpected $end in document.parser.class.inc.php(705)

    all that shows is the error,

    would it because I changed the snippet name to test ?

    i’m calling it as ContactForm2

    Did you change the snippet name to `test` or `ContactForm2` huh

    Also, make sure you didn’t leave the PHP tags (e.g. <?php or ?>) in the code.
      • 4273
      • 356 Posts
      actually i meant to say to test it i named it to ContactForm2

      and yes I know about leaving out the <?php the snippet is setup properly I believe but still receives the error
        SMF Bookmark Mod - check it out
        http://mods.simplemachines.org/index.php?mod=350
      • The unexpected $end error occurs when your code structurally incorrect, in other words, you are missing a closing brace } in a control statement (i.e. if, while, for, foreach, etc.).
          • 7923
          • 4,213 Posts
          Quote from: bugsmi0 at Jul 25, 2006, 11:30 PM

          and yes I know about leaving out the <?php the snippet is setup properly I believe but still receives the error
          Just to be sure, you did remove the ?> at the end of the snippet too, right?


            "He can have a lollipop any time he wants to. That's what it means to be a programmer."
            • 4273
            • 356 Posts
            this is the same code I copied and pasted from above

            // Email / Contact Form
            //
            // Simple XHTML validating email form, that sends different subjects and messages. 
            // people in a company.
            //
            // revised by G Flower 21 July 2006
            //
            // Version 1.0
            // September 9, 2005
            // [email protected]
            //
            
            // DO NOT ALTER THE FOLLOWING TWO LINES
            $recipient_array = array();
            
            ///////////////////////////////////
            //  <-----  BEGIN CONFIG  ----->
            ///////////////////////////////////
            // Edit only what's between the quotation marks in the lines below.
            // These will be the subjects that your users can choose from popup
            // lists. You can have as many as you want. Each one must be set up like so:
            // Make sure to remove empty ones that you aren't using. Just delete the entire line.
            
            // Generic email to use for all parts. You can edit
            // the individual instances for more control.
            // Defaults to the built-in email notification account which is set in the System Configuration.
            // Can be set by using as follows:
            // [[ContactForm? &sendTo=`[email protected]`]]
            $email = (isset($sendTo))? $sendTo : '[(emailsender)]';
            
            
            // enter the subject line
            
            $the_subject = "Web Inquiry";
            
            
            // Recipient ... add or remove lines as needed
            // Format (as few or as many as desired): 
            // $recipient_array["Your Text Here"] = '[email protected]';
            $recipient_array["Sales"] = '[email protected]';
            $recipient_array["Accounts"] = '[email protected]';
            $recipient_array["Website"] = '[email protected]';
            
            // enter "static" in order to use the solo recipient
            $recipient_type = "";
            $static_recipient = "$email";
            
            // Instructions 
            $instructions = "Please select the type of message you'd like to send so we can route it properly. All fields are required.";
            
            // Success Message
            $success = "Thanks for contacting [(site_url)]. Someone will get back to you soon. You may submit another message in the form below.";
            
            // Class for containing Success Message <p>
            $successClass = "message";
            
            // Failure <p> class
            $failClass = "error";
            
            // Empy Field failure message
            $emptyFields = "One of the fields was left blank. Please put something in all fields.";
            
            // General failure message
            $generalFail = "Sorry, there was an error! Please try again later.";
            
            // Bad email failure message
            $failedEmail= (isset($_POST['email']))? $_POST['email']: '';
            $emailFail = "The email address you supplied does not appear to be valid. Please try again.";
            
            // Debug mode for testing
            $debug = false;
            
            //  <-----  END CONFIG  ----->
            ///////////////////////////////////
            $SendMail = '';
            if ($debug && $_POST) {
            	$SendMail .= "POST variables from Document ID [*id*]:\n";
            	foreach ($_POST as $key => $value) {
            		$SendMail .= "\t$key => $value\n";
            	}
            }
            
            $from= '';
            $from_email= '';
            $message= '';
            
            $postSend= isset($_POST['send'])? $_POST['send']: 'false';
            if ($postSend == 'true') { 
                $todata = explode("|", $_POST['to']);
                $to = ($recipient_type=="static") ? $static_recipient : $todata[0];
                $from = $_POST['name'];
                $from_email = $_POST['email'];
                $the_subject .= " - " . $todata[1];
                $message = $_POST['message'];
                if ( ($from == '')||($from_email == '')||($message == '') ) {
                    $SendMail .= "<p class=\"$failClass\">$emptyFields</p>";
                } elseif (eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$", $from_email)) {
                    $subject = $the_subject;
                    $headers = "From: $from <$from_email>\r\n";
                    
                    // clean out potential tomfoolery...
                    $message = $modx->stripTags($message);
                    
                    $body = "Name: $from\nEmail: $from_email\nMessage:\n\n" . $message;
                    if (mail($to, $subject, $body, $headers)) {
                        $SendMail .= "<p class=\"$successClass\">$success</p>";
                        $SendMail .= ($debug) ? "<p>$to\n$headers\n$subject\n$body</p>" : '';
                        $from="";
                        $from_email="";
                        $message="";
                    } else {
                        $SendMail .= "<p class='$failClass'>$generalFail</p>";
                        $send = "false";
                    }
                } else {
                    $SendMail .= "<p class=\"$failClass\">$emailFail</p>";
                    $send = "false";
                } 
            } else {
                $SendMail .= "<p>$instructions</p>";
            }
            $SendMail .=<<<EOD
            <div class="emailform">
                <form method="post" name="EmailForm" id="EmailForm" action="[~[*id*]~]" >
                    <fieldset>
                        <input type="hidden" name="send" value="true" />
                        <label for="name">Your Name: <input type="text" name="name" id="name" size="30" value="$from" /></label>
            
                        <label for="email">Your Email Address: <input type="text" name="email" id="email" size="30" value="$from_email" /></label>
            
                        <label for="to">Regarding: 
                        <select name="to" id="to">
            EOD;
            
                    foreach ($recipient_array as $key=>$value) {
                        $SendMail .= "<option value=\"{$value}|{$key}\">{$key}</option>\n";
                    }
            
            $SendMail .=<<<EOD
                        
                        </select>
                          </label>
                        <label for="message">Message: 
                        <textarea cols="50" rows="10" name="message" id="message">$message</textarea>
                        </label>
                        
                        <label>Send this message:<input type="submit" value="Send" class="button" /></label>
                    </fieldset>
                </form>
            </div>
            EOD;
            


            calling it [!ContactForm!], I also tried it like [[ContactForm]]

            what’s happening now is there’s no error and no form just blank page
              SMF Bookmark Mod - check it out
              http://mods.simplemachines.org/index.php?mod=350
              • 10472
              • 22 Posts
              My fault entirely - it looks like I haven’t pasted all the code. So here it is in its entirety:

              // Email / Contact Form
              //
              // Simple XHTML validating email form, that sends different subjects and messages.
              // people in a company.
              //
              // revised by G Flower 21 July 2006
              //
              // Version 1.0
              // September 9, 2005
              // [email protected]
              //

              // DO NOT ALTER THE FOLLOWING TWO LINES
              $recipient_array = array();

              ///////////////////////////////////
              // <----- BEGIN CONFIG ----->
              ///////////////////////////////////
              // Edit only what’s between the quotation marks in the lines below.
              // These will be the subjects that your users can choose from popup
              // lists. You can have as many as you want. Each one must be set up like so:
              // Make sure to remove empty ones that you aren’t using. Just delete the entire line.

              // Generic email to use for all parts. You can edit
              // the individual instances for more control.
              // Defaults to the built-in email notification account which is set in the System Configuration.
              // Can be set by using as follows:
              // [[ContactForm? &sendTo=`[email protected]`]]
              $email = (isset($sendTo))? $sendTo : ’[(emailsender)]’;


              // enter the subject line

              $the_subject = "Web Inquiry";


              // Recipient ... add or remove lines as needed
              // Format (as few or as many as desired):
              // $recipient_array["Your Text Here"] = ’[email protected]’;
              $recipient_array["Factor/retailer software"] = ’[email protected]’;
              $recipient_array["Workshop software"] = ’[email protected]’;
              $recipient_array["Tyre software"] = ’[email protected]’;
              $recipient_array["E-commerce"] = ’[email protected]’;
              $recipient_array["Support enquiry"] = ’[email protected]’;
              $recipient_array["Website enquiry"] = ’[email protected]’;

              // enter "static" in order to use the solo recipient
              $recipient_type = "";
              $static_recipient = "$email";

              // Instructions
              $instructions = "Please select the type of message you’d like to send so we can route it properly. All fields are required.";

              // Success Message
              $success = "Thanks for contacting [(site_url)]. Someone will get back to you soon. You may submit another message in the form below.";

              // Class for containing Success Message <p>
              $successClass = "message";

              // Failure <p> class
              $failClass = "error";

              // Empy Field failure message
              $emptyFields = "One of the fields was left blank. Please put something in all fields.";

              // General failure message
              $generalFail = "Sorry, there was an error! Please try again later.";

              // Bad email failure message
              $failedEmail= (isset($_POST[’email’]))? $_POST[’email’]: ’’;
              $emailFail = "The email address you supplied does not appear to be valid. Please try again.";

              // Debug mode for testing
              $debug = false;

              // <----- END CONFIG ----->
              ///////////////////////////////////
              $SendMail = ’’;
              if ($debug && $_POST) {
              $SendMail .= "POST variables from Document ID [*id*]:\n";
              foreach ($_POST as $key => $value) {
              $SendMail .= "\t$key => $value\n";
              }
              }

              $from= ’’;
              $from_email= ’’;
              $message= ’’;

              $postSend= isset($_POST[’send’])? $_POST[’send’]: ’false’;
              if ($postSend == ’true’) {
              $todata = explode("|", $_POST[’to’]);
              $to = ($recipient_type=="static") ? $static_recipient : $todata[0];
              $from = $_POST[’name’];
              $from_email = $_POST[’email’];
              $the_subject .= " - " . $todata[1];
              $message = $_POST[’message’];
              if ( ($from == ’’)||($from_email == ’’)||($message == ’’) ) {
              $SendMail .= "<p class=\"$failClass\">$emptyFields</p>";
              } elseif (eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$", $from_email)) {
              $subject = $the_subject;
              $headers = "From: $from <$from_email>\r\n";

              // clean out potential tomfoolery...
              $message = $modx->stripTags($message);

              $body = "Name: $from\nEmail: $from_email\nMessage:\n\n" . $message;
              if (mail($to, $subject, $body, $headers)) {
              $SendMail .= "<p class=\"$successClass\">$success</p>";
              $SendMail .= ($debug) ? "<p>$to\n$headers\n$subject\n$body</p>" : ’’;
              $from="";
              $from_email="";
              $message="";
              } else {
              $SendMail .= "<p class=’$failClass’>$generalFail</p>";
              $send = "false";
              }
              } else {
              $SendMail .= "<p class=\"$failClass\">$emailFail</p>";
              $send = "false";
              }
              } else {
              $SendMail .= "<p>$instructions</p>";
              }
              $SendMail .=<<<EOD
              <div class="emailform">
              <form method="post" name="EmailForm" id="EmailForm" action="[~[*id*]~]" >
              <fieldset>
              <input type="hidden" name="send" value="true" />
              <label for="name">Your Name: <input type="text" name="name" id="name" size="30" value="$from" /></label>

              <label for="email">Your Email Address: <input type="text" name="email" id="email" size="30" value="$from_email" /></label>

              <label for="to">Regarding:
              <select name="to" id="to">
              EOD;

              foreach ($recipient_array as $key=>$value) {
              $SendMail .= "<option value=\"{$value}|{$key}\">{$key}</option>\n";
              }

              $SendMail .=<<<EOD

              </select>
              </label>
              <label for="message">Message:
              <textarea cols="50" rows="10" name="message" id="message">$message</textarea>
              </label>

              <label>Send this message:<input type="submit" value="Send" class="button" /></label>
              </fieldset>
              </form>
              </div>
              EOD;

              return $SendMail;


                • 4273
                • 356 Posts
                wow I don’t know weather to stone you to death or give you a big hug he he
                thanks it worked perfectly

                is it possible to have an additional $instructions appear for members logged in ?
                  SMF Bookmark Mod - check it out
                  http://mods.simplemachines.org/index.php?mod=350
                  • 10472
                  • 22 Posts
                  Got there in the end! Some valuable lessons learned from my first posts!

                  What exactly did you mean by additional instructions?
                    • 4273
                    • 356 Posts
                    in the snippet it has $instructions that puts out instructions that people will see on the form

                    I was wondering if it possible to add an additional set of $instructions that shows when a member is logged instead of the default msg
                      SMF Bookmark Mod - check it out
                      http://mods.simplemachines.org/index.php?mod=350