Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8582415
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T21:17:15+00:00 2026-06-11T21:17:15+00:00

I’m trying to submit a form via custom page template but the problem is

  • 0

I’m trying to submit a form via custom page template but the problem is that it only works with form action="<?php the_permalink() ?>" and I need the form to be submitted and redirected to something like this form action="<?php bloginfo('url')?>/message-sent?id=<?php the_ID() ?>"

Full code:

<?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 <no-reply@xyz.com>' . "\r\n";
            wp_mail($emailTo, $subject, $body, $headers);
            $emailSent = true;

} ?>




<section class="box grid_9 list_posts">
<div class="inner">
                <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<div <?php post_class() ?> id="post-<?php the_ID(); ?>">
<div class="entry-content">
<div class="contact-form clearfix">
                            <?php if(isset($emailSent) && $emailSent == true) { ?>
<div class="thanks">
<?php _e('Thanks, your email was sent successfully.', 'framework') ?>
</div>
                            <?php } else { ?>
                                <?php the_content(); ?>
                                <?php if(isset($hasError) || isset($captchaError)) { ?>
<p class="error"><?php _e('Sorry, an error occured.', 'framework') ?>

                                <?php } ?>






<form action="<?php the_permalink()?>" id="contactForm" method="post">
<ul class="contactform">



<li>
                                            <input type="email" name="email" id="email" value="<?php if(isset($_POST['email']))  echo $_POST['email'];?>" class="required requiredField email" required="required" />
                                        </li>

<li class="buttons">

                                            <input type="hidden" name="submitted" id="submitted" value="true" />
                                            <input type="submit" value="Remind Me!"></input>
                                        </li>
</ul></form>






                            <?php } ?></div>
</div>
</div>
                    <?php endwhile; else: ?>
<div id="post-0" <?php post_class() ?>>
<h1 class="entry-title"><?php _e('Error 404 - Not Found', 'framework') ?></h1>

</div>
                <?php endif; ?></div>
</section>

I got no php errors in log, page is redirected successfully, but no email is sent. When using the_permalink, everything works just fine.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T21:17:16+00:00Added an answer on June 11, 2026 at 9:17 pm

    When submitting the form data to a different script, make sure the code for (validating the input and) sending the email is in that very file.

    Otherwise, your URL /message-sent might rewrite to a completely different script and the script with the above code isn’t involved at all once the submit button gets clicked.

    Did that held you? Feel free, to ask, if my wording is incomprehensible or if my description isn’t clear to you

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to create an if statement in PHP that prevents a single post
Basically, what I'm trying to create is a page of div tags, each has
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I am trying to understand how to use SyndicationItem to display feed which is
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I would like to count the length of a string with PHP. The string

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.