Problems, need help? Have a tip or advice? Post it here.
28 posts Page 2 of 3
I just tried putting it outside of the <cms:if k_success> tag and it executed (Obviously with an error) - so what would be my next step?
It should execute without any error before we can move it inside the form. Please try fixing the error first.

As for hard-coded variables - are they hard coded to be frm_variablename
No. The frm_variables are available only within a form's k_success condition.
By hard coded strings I mean don't use variables at all. Rather put in specific values e.g.
Code: Select all
$mail->From = 'yourmail@gmail.com';

Hope this helps.
The error was that the fields were empty (I assume as it was attempting to load empty fields from the form).
I can't get any PHP at all to execute from within k_success at all for some reason - I tried just a simple php echo and still got nothing when I pressed the submit button!
Thanks
I can't get any PHP at all to execute from within k_success at all for some reason - I tried just a simple php echo and still got nothing when I pressed the submit button!
Are you using cms:redirect in the success condition? If yes, that would explain it as the PHP would get executed but the page will refresh before the output is seen.
No cms:redirect is present (there was at one point for the sake of testing, as it was present in the original couch form) but it does seem to be refreshing the page when I hit submit.
Just on the off chance I'm going to post my button markup in case anything is obviously wrong.
I can't figure out what I could possibly be doing wrong here! It doesn't seem like any PHP will execute inside k_success for me and I genuinely can't figure out why - any ideas at this point would be welcome.
Button markup:
Code: Select all
<input type='submit' id='send_message' value='Submit' />


Thanks

Edit: Would it be more helpful if I posted the code for my entire form? I'm getting pretty desperate at this point! Been working on this all day, seemingly to no avail!
Please remove the cms:redirect while you are debugging. Will let you see the output of cms:php.
I already removed it - as I said there is no redirect present. I did briefly reinstate it as an experiment while trying to figure out what was going on but it is no longer there. I've even tried stripping it down to just the cms:form element, the submit button and the k_success part - still no joy.
I have tried it with a simple single echo script as well, still nothing - I just don't seem to be able to get any PHP to execute inside k_success.

Edit: The page *does* still seem to be refreshing when I hit submit though.

Edit II: If it is refreshing, that might explain why the email isn't sending (still using the hard-coded values at the moment as you suggested) as it did seem like there was a slight delay before sending (when it was outside of cms:if).
Please paste your full form here.
Obviously have removed actual email addresses and passwords - the script itself functions outside of cms:if.

Code: Select all
<cms:form method='post' id='contact_form' action=''>
   <ul id="contactPageFormList">
      <li>
         <label for="name"><p class="contact_labels">Name:</p></label>
         <cms:input type='text' name='name' id='contact_name' required='1' />
         <cms:if k_error_name>
            <p class='contact_error'>Please provide a name.</p>
         </cms:if>   
      </li>
      <li>
         <label for="email"><p class="contact_labels">Email Address:</p></label>
         <cms:input type='text' name='email' id='contact_email' required='1' validator='email' />
         <cms:if k_error_email>
            <p class='contact_error'>Please provide a valid Email.</p>
         </cms:if>
      </li>
      <li>
         <label for="message"><p class="contact_labels">Message:</p></label>
         <cms:input type='textarea' name='message' id='contact_message' required='1' rows="20" cols="30"></cms:input>
         <cms:if k_error_message>
            <p class='contact_error'>Please enter a message.</p>
         </cms:if>
      </li>
      <li>
                                          
         <cms:if k_success>
         
            <!--PHPMailer -->
            <cms:php>echo 'test';</cms:php>
    
            <cms:php>
               require 'PHPMailer/PHPMailerAutoload.php';
               
               $mail = new PHPMailer;
               
                  $mail->isSMTP();   // Set mailer to use SMTP
                  $mail->Host = 'localhost';  // Specify main and backup SMTP servers
                  $mail->SMTPAuth = true;    // Enable SMTP authentication
                  $mail->Username = 'email@goeshere.com';  // SMTP username
                  $mail->Password = 'password';   // SMTP password
                  $mail->Port = 25;   // TCP port to connect to
                  
                  $mail->SetFrom('email@goeshere.com');
                                                      
                  $mail->addAddress('email@goeshere.com', 'Name');  // Add a recipient
                  $mail->addReplyTo('email@goeshere.com', 'Name'); //make this the customer address?
                  
                  $mail->WordWrap = 50;    // Set word wrap to 50 characters
                  //$mail->isHTML(true);     // Set email format to HTML
                  
                  $mail->From = 'email@goeshere.com';
                  $mail->Subject = 'New Contact Form Testing Email.  Please Disregard.';
                  $mail->FromName = 'Name';
                  $mail->Body    = 'This is a test email sent from the PHPMailer Script.';
                  
                  if(!$mail->send()) {
                     echo 'Message could not be sent.';
                     echo 'Mailer Error: ' . $mail->ErrorInfo;
                  } else {
                     echo 'Message has been sent';
                  }
            </cms:php>
   </cms:if>
                     
      
         <div id="contactSubmitWrapper">
            <input type='submit' id='send_message' value='Submit' />
         </div>
      </li>
   </ul>
</cms:form>
Thanks.

I commented out the phpmailer part and the <cms:php> echoing 'hello' is working just fine for me.
Maybe your CSS is making the 'hello' not manifestly visible.

Will play around with phpmailer next.
I tested your code (using GMail as I am on localhost) and it is working just fine.
28 posts Page 2 of 3