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

  • Home
  • SEARCH
  • 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 6787617
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T17:23:16+00:00 2026-05-26T17:23:16+00:00

I’m a complete newbee in php (started just last week) Issue is like this:

  • 0

I’m a complete newbee in php (started just last week)

Issue is like this:

Basically, I was trying to ensure that once a sub-form is filled, then it is not altered. So, I used !isset to display the sub-form (i.e. if !isset is true) and if !isset is false, then it hides that sub-form and shows the next sub-form (the individuals form has only been designed).

        <?php include($_SERVER['DOCUMENT_ROOT'].'/officespace/includes/functions.php');

    echo'<html>
        <head>
            <title> Create </title>
        </head>

    <body>';

    if(!isset($_POST["Category"])){
    /* if no category is selected, then this code will display the form to select the category*/

    Echo "Pls Select Category before clicking on Submit Category";
    /* Breaking out of PHP here, to make the form sticky by using a php code inside form action*/
    ?>
    <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
    <fieldset>
        <legend>Select the Category of Person: </legend><br />
            <input type="radio" name="Category" value="Individual" /> Individual<br /><br />
            <input type="radio" name="Category" value="Company, Pvt Ltd" /> Company, Pvt Ltd<br /><br />
            <input type="radio" name="Category" value="Company, Ltd" /> Company, Ltd<br /><br />
            <input type="radio" name="Category" value="Partnership Firm" /> Partnership Firm<br /><br />
            <input type="radio" name="Category" value="LLP Firm" /> LLP Firm<br /><br />
            <input type="radio" name="Category" value="HUF" /> HUF<br /><br />
            <input type="submit" name='Submit Category' value="Submit Category" /><br />
    </fieldset>
    </form>
    <?php
    } Else {

    $Category = $_POST["Category"];


        Echo "$Category";
        Echo "<br />";
    /* Using swich statement to test the value of Category, and accordingly echo appropriate forms*/
        switch ($Category) {
            case "Individual":
            if(!isset($_POST['Submit_Data_for_Individual'])){

            //if no data for individual is submitted,
            //then this code will display the form to enter and submit data for Individual

                Echo  /*displays message*/
                "Pls Enter the Data for the Individual";
    ?>
                <form action="<?php Echo $_SERVER['PHP_SELF']; ?>" method="post"> 
                <fieldset>
                <br />
                    First Namee: <input type="text" name="Individual_First_Name" />
                <br />
                    Middle Name: <input type="text" name="Individual_Middle_Name" />
                <br />
                    Last Name: <input type="text" name="Individual_Last_Name" />
                <br />
                    Date of Birth: <input type="text" name="date_of_birth/incorporation" />
                <br />
                    Gender: 
                <br />
                    <input type="radio" name="Gender" value="male" /> Male
                <br />
                    <input type="radio" name="Gender" value="female" /> Female
                <br />
                    Email 1: <input type="text" name="email_1" />
                <br />
                <input type="submit" name="Submit_Data_for_Individual" value="Submit Data for Individual" />
                </fieldset>
                </form>
    <?php                               
                }Else
                {
                $email_1 = $_POST["email_1"];
                $Gender = $_POST["Gender"];

                validate_email($email_1); // this is a custom function which i made
                Echo $Gender; // just to see if value has been passes. problem lies here because its not showing anything

                // run other validations here
                // and if all valid then run mysqli insert query for individuals record
                }

                break;
            case "Company, Pvt Ltd":
                echo "Company, Pvt Ltd";
                break;
            case "Company, Ltd":
                echo "Company, Ltd";
                break;
            case "Company, Ltd":
                echo "Company, Ltd";
                break;
            case "Partnership Firm":
                echo "Partnership Firm";
                break;
            case "LLP Firm":
                echo "LLP Firm";
                break;
            case "HUF":
                echo "HUF";
                break;
            case NULL:
                echo "Error: nothing selected";
                break;

        }
    }

    echo '</body>


    </html>';

    ?>
  • 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-05-26T17:23:16+00:00Added an answer on May 26, 2026 at 5:23 pm

    Is see one problem immediately.

    You are checking for a form input called Submit Data for Individual, but that is the value of a submit button which has no name attribute. Set a name='submit-data' attribute on the submit button and change the conditional to check for the name instead of its value:

    // This will never match.
    if(!isset($_POST["Submit Data for Individual"])){
    
    // Change it to
    if(!isset($_POST["submit-data"])){
    
    // Then change this
    <input type="submit" value="Submit Data for Individual" />
    
    // To this:
    <input type="submit" name='submit-data' value="Submit Data for Individual" />
    

    Additionally, the default case in a switch statement uses a default keyword:

        // You may safely change this:
        case NULL:
            echo "Error: nothing selected";
            break;
    
        // To this:
        default:
            echo "Error: nothing selected";
            break;
    

    Addendum:

    The following code is never reachable, since the form posts to another script, create.php. If you change the <form> action attribute to post back to <?php $_SERVER['PHP_SELF'];?> instead of to create.php, you should see the else case. Right now, it doesn’t work because your if tests that $_POST["submit-data"] is set. It can only be set if the form has been submitted, but the form submits to an external script.

            // This else case can never be reached...
            }Else
            {   
            validate_email($_POST["email_1"]); // this is a custom function which i made
            Echo $_POST["Gender"]; // just to see if value has been passes. problem lies here because its not showing anything
    
            // run other validations here
            // and if all valid then run mysqli insert query for individuals record
            }
    

    To fix this and see your Gender echoed out, temporarily change

    <form action="create.php" method="post"> 
    // change to
    <form action="' . $_SERVER['PHP_SELF'] . '" method="post"> 
    

    Addendum 2

    You are checking if Category is set, but after posting the user form, it will not be:

    // Change
    if(!isset($_POST["Category"])){
    
    // To check that the user form was not submitted
    if (!isset($_POST["Category"]) && !isset($_POST['submit-data'])) {
    

    Then you need to test if the user form was submitted. Before the Else { $Category = $_POST['Category']; section, add an else if to process the user form.

    if (!isset($_POST["Category"]) && !isset($_POST['submit-data'])) {
      // Show the Category form...
    }
    // Process the user form...
    else if (isset($_POST['submit-data'])) {
        validate_email($_POST["email_1"]); // this is a custom function which i made
        Echo $_POST["Gender"];
    }
    // Now process the categories or show the user form...
    else {
        $Category = $_POST['Category'];
        // etc...
    }
    

    Finally, remove the whole Else block from your individual case, as it cannot be used there.

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm trying to create an if statement in PHP that prevents a single post
I would like to count the length of a string with PHP. The string
For some reason, after submitting a string like this Jack’s Spindle from a text
Basically, what I'm trying to create is a page of div tags, each has
this is what i have right now Drawing an RSS feed into the php,
I've got a string that has curly quotes in it. I'd like to replace
I have some data like this: 1 2 3 4 5 9 2 6
link Im having trouble converting the html entites into html characters, (&# 8217;) i

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.