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 9132673
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T08:21:09+00:00 2026-06-17T08:21:09+00:00

I have a page which is split into 3 parts with 2 submit buttons:

  • 0

I have a page which is split into 3 parts with 2 submit buttons:

Part 1: Contains a module drop down menu. User selects option from drop down menu and submits. Everytime it is submitted, it changes part 2 and part 3 is hidden. After submission drop down menu goes back to Please Select option.

Part 2: Contains Assessment drop down menu, only appears after user has submitted part 1. When this part is submitted by user selecting option from Assessment drop down menu and clicking on submit button, drop down menu goes back to Please Select and part 3 appears. Part 3 changes everytime part 2 is submitted with different options.

Part 3: Display details from part 2. Only appears and changes depending on Assessment chosen and submitted from part 2. If user submits from part 1, then this part is hidden.

My question is what is the right structure in order to be able to match what I stated above. What I mean is that where does the if statements go, what goes in the if statements and when do I close the if statements?

Below is my code, problem is that if I click on submit button in part 2, instead of display part 3, it just removes parts 2 and just shows part 3 where part 2 is, so I believe my page structure is incorrect. I commented where each part is.

    //PART 1

    <form action="<?php echo htmlentities($_SERVER['PHP_SELF']); ?>" method="post">
    <table>
    <tr>
    <th>Module: 
    <select name="modules" id="modulesDrop">
    <option value="">Please Select</option>
    <option value="1">Art</option>
    <option value="2">ICT</option>
    <option value="3">Business</option>
    </select>
    </th>
    </tr>
    </table>
    <p><input id="moduleSubmit" type="submit" value="Submit Module" name="moduleSubmit" /></p>
    </form>

    <?php

    if (isset($_POST['moduleSubmit']) || isset($_POST['sessionSubmit'])){   

    //PART 2

    if($_POST['modules'] == ''){
    $pHTML = "<span style='color: red'>Please Select a Module</span>";
    }else if($sqlnum == 0){
    $pHTML = "<span style='color: red'>Sorry, You have No Assessments under this Module</span>";
    } else{

    $sessionHTML = '';
    $sessionHTML = '<select name="session" id="sessionsDrop">'.PHP_EOL;
    $sessionHTML .= '<option value="">Please Select</option>'.PHP_EOL;       
    $sessionHTML .= '<option value="one">AAA</option>'.PHP_EOL;     
    $sessionHTML .= '<option value="two">AAB</option>'.PHP_EOL;     
    $sessionHTML .= '<option value="three">AAC</option>'.PHP_EOL;  
    $sessionHTML .= '</select>';  

    $assessmentform = "
    <form action='".htmlentities($_SERVER['PHP_SELF'])."' method='post' id='assessmentForm'>
    <p id='warnings'>{$pHTML}</p>
    <p><strong>Assessments:</strong> {$sessionHTML} </p>   
    <p><input id='sessionSubmit' type='submit' value='View Assessment Details' name='sessionSubmit' /></p>
    </form>";

    echo $assessmentform;

     }
        }

    if (isset($_POST['sessionSubmit'])) {

    //PART 3

if($_POST['session'] == ''){
$sHTML = "<span style='color: red'>Please Select a Session</span>";
} else{

    $sessiondetails ="
    <p id='warnings'>{$sHTML}</p>
    <p>You have selected an Assessment where the details will be displayed here:</p>
    ";  

    echo $sessiondetails;

    }
}
  • 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-17T08:21:10+00:00Added an answer on June 17, 2026 at 8:21 am

    You really need to separate data logic (i.e. what you’re asking your PHP to do), and the rendering (what you’re asking your HTML to do). I’d open your script with PHP functionality, determine what you want to show, and put your HTML into separate phtml files.

    I’d also include a hidden field, indicating what step the user is currently on. This would allow you to do something like:

    <?php
       if (isset($_POST['step'] && $step = $_POST['step']) {
          // The user has submitted a form
       } else {
          // They're fresh visitors
          $step = 0;
       }
    ?>
    
    <!-- HTML markup here -->
    
    <form method="post">
    
       <input type="hidden" name="step" value="<?=$step + 1?>">
    
       <? if ($step == 2): ?>
    
           <? if (!$_POST['modules']): ?>
               <span style='color: red'>Please Select a Module</span>
           <? elseif (!$sqlnum): ?>
               <span style='color: red'>Sorry, You have No Assessments under this Module</span>
           <? endif; ?>
    
       <? endif; ?>
    
       <? // etc. etc. ?>
    
    </form>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following scenario. I have a search page which is split into
I have a web form which is split up into several HTML pages. I
I have a page split in 3. First part is a list of links
I have one page with textarea which content is saved into database. The content
I have page which is redirected from htaccess. now I can pass the German
I have a page which loads and then I do some JQuery upon it.
I have this page which has three peson searchs on them. Basically it's a
I have a page which is Https, I am pulling some rss feeds using
I have a page which when an a link is clicked (which must remain
I have one Page which is displaying details of some Client. I am using

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.