I have a form on the home page, which when user submits, the action takes him to another page. That another page is using my custom made page template page-quiz.php. So for the form submit action I'm using this file. Unfortunately, when I submit the form, I get page not found.

The actual page is created inside admin dashboard. It seems like the template file name and page url is different. I tried making the url the same as the name of the temlate file page-quiz.php but I get the same page not found problem.

My index.php form code:

...<div class="forma">
    <h2 style="text-align: center; color: #E45E5D; font-weight: 700;">Register for quiz</h2>
        <form action="page-quiz.php" method="post">
            <input type="text" placeholder="Enter Email" name="asd" required>
                <input type="text" placeholder="Enter full name" name="kasd" required>

</div> ....


 * The template for displaying all pages
 * Template Name: Quiz
 * This is the template that displays all pages by default.
 * Please note that this is the WordPress construct of pages
 * and that other 'pages' on your WordPress site may use a
 * different template.
 * @link https://developer.wordpress.org/themes/basics/template-hierarchy/
 * @package okindk
get_header('header-quiz'); ?>

    <div id="primary" class="content-area">
        <main id="main" class="site-main">

      <div id="container" class="container container_quiz">
        <div class="row">
          <div class="col-lg-12">
            <div id="questions" class="lead">

            <p id="options" class="center-block">

              <p id="progress">Question x of y</p>

           <?php echo $_SESSION\["email"\]; ?>
        </main><!-- #main -->
    </div><!-- #primary -->


How can I get around this?

enter image description here

  • 1
    In WordPress this does not look right: <form action="page-quiz.php" method="post"> | You have to do something like get_template_directory_uri() to get to the file path or you can link to mysite(dot)com/quiz – user23355 Dec 14 '17 at 18:53
  • Exactly - you need to use the page permalink rather than a link to your template file. You'll also want to add a conditional, above get_header() - to check for $_POST['asd'] and $_POST['kasd'] - if either are empty, show the form so the visitor must enter your required information; if they are both set, show the quiz. – WebElaine Dec 14 '17 at 20:26
  • Can you guys explain how to use get_template_directory_uri() in my case, because I can't make it work when using inside Action – Limpuls Dec 14 '17 at 20:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.