title: Contact page template - redirect to 'thank you page' not working
body: <p>I'm trying to submit a form via custom page template but the problem is that it only works with <code>form action="&lt;?php the_permalink() ?&gt;"</code> and I need the form to be submitted and redirected to something like this <code>form action="&lt;?php bloginfo('url')?&gt;/message-sent?id=&lt;?php the_ID() ?&gt;"</code></p>
  
  <p>Full code:</p>
  
  <pre><code>&lt;?php 
  $emailError = '';
  if(isset($_POST['submitted'])) {
  
              $email = trim($_POST['email']);
  
  
  
                  //setup self email address
                  $emailTo = $email; 
  
  
              $subject = "[reminder] Don't forget to download " . get_the_title();
              $body = "Name: $name \n\nEmail: $email \n\nComments: $comments";
              $headers = 'From: Myemail reminders &lt;no-reply@xyz.com&gt;' . "\r\n";
              wp_mail($emailTo, $subject, $body, $headers);
              $emailSent = true;
  
  } ?&gt;
  
  
  
  
  &lt;section class="box grid_9 list_posts"&gt;
  &lt;div class="inner"&gt;
                  &lt;?php if (have_posts()) : while (have_posts()) : the_post(); ?&gt;
  &lt;div &lt;?php post_class() ?&gt; id="post-&lt;?php the_ID(); ?&gt;"&gt;
  &lt;div class="entry-content"&gt;
  &lt;div class="contact-form clearfix"&gt;
                              &lt;?php if(isset($emailSent) &amp;&amp; $emailSent == true) { ?&gt;
  &lt;div class="thanks"&gt;
  &lt;?php _e('Thanks, your email was sent successfully.', 'framework') ?&gt;
  &lt;/div&gt;
                              &lt;?php } else { ?&gt;
                                  &lt;?php the_content(); ?&gt;
                                  &lt;?php if(isset($hasError) || isset($captchaError)) { ?&gt;
  &lt;p class="error"&gt;&lt;?php _e('Sorry, an error occured.', 'framework') ?&gt;
  
                                  &lt;?php } ?&gt;
  
  
  
  
  
  
  &lt;form action="&lt;?php the_permalink()?&gt;" id="contactForm" method="post"&gt;
  &lt;ul class="contactform"&gt;
  
  
  
  &lt;li&gt;
                                              &lt;input type="email" name="email" id="email" value="&lt;?php if(isset($_POST['email']))  echo $_POST['email'];?&gt;" class="required requiredField email" required="required" /&gt;
                                          &lt;/li&gt;
  
  &lt;li class="buttons"&gt;
  
                                              &lt;input type="hidden" name="submitted" id="submitted" value="true" /&gt;
                                              &lt;input type="submit" value="Remind Me!"&gt;&lt;/input&gt;
                                          &lt;/li&gt;
  &lt;/ul&gt;&lt;/form&gt;
  
  
  
  
  
  
                              &lt;?php } ?&gt;&lt;/div&gt;
  &lt;/div&gt;
  &lt;/div&gt;
                      &lt;?php endwhile; else: ?&gt;
  &lt;div id="post-0" &lt;?php post_class() ?&gt;&gt;
  &lt;h1 class="entry-title"&gt;&lt;?php _e('Error 404 - Not Found', 'framework') ?&gt;&lt;/h1&gt;
  
  &lt;/div&gt;
                  &lt;?php endif; ?&gt;&lt;/div&gt;
  &lt;/section&gt;
  </code></pre>
  
  <p>I got no php errors in log, page is redirected successfully, but no email is sent. When using the_permalink, everything works just fine.</p>