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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T14:17:36+00:00 2026-06-18T14:17:36+00:00

This is my PHP code The problem points I have mentioned in comments inside

  • 0

This is my PHP code

The problem points I have mentioned in comments inside the code portion

if(isset($_POST['submit']))
{
    if(isset($_POST['rdoption1']))
    {
        $var1 = $_POST["rdoption1"];
    }
    if(isset($_POST['rdoption2']))
    {
        $var2 = $_POST["rdoption2"];
    }
    if(!isset($_POST['rdoption1']))
    {
        $message = "Please select Option1";
    }
    elseif(!isset($_POST['rdoption2']))
    {
        $message = "Please select Option2";
    }
    elseif($_POST['rdoption2'] == "checkSetXY")
    {
        if($_POST["valXLocation"] == "")
        {
            $message = "You forget to enter X value.";
        }
        elseif($_POST["valYLocation"] == "")
        {
            $message = "You forget to enter Y value.";
        }
    } // till here all is good. I get all error messages if anything is left vacant or not clicked on radio button
    elseif(empty($_POST['txtoption3'])) //this is not working //the issue is if i select rdoption1  any option and rdoption2 checkDefault next code logic work.. but next code logic does not work when i click on the radio of checkSetXY and enter x and y values.. It simply does not execute code further..
    {
        $message = "Please enter your name.";
    }
                else
    {               
        //insert into db
                 }
       }

This is html form with PHP echos
Here I’m getting messages where they shall be but not when I select checkSetXY value

        <?php if(!empty($message)){ echo $message; } ?>

        <form id="form1" name="form1" method="post" action="form1.php">

          Space portion:
              <input type="radio" name="rdoption1" value="RJ"/>space 1
              <input type="radio" name="rdoption1" value="SM" />space 2


            Pixel Location
                <div class="formText">
                <input type="radio" name="rdoption2" value="checkSetXY"/> Specify Location
                    X: <input type="text" id="locField" name="valXLocation">  
                    Y: <input type="text" id="locField" name="valYLocation"> 
                <input type="radio" name="rdoption2" value="checkDefault"/>Default

                <input type="text" class="input" name="txtoption3">
                <input type="submit" name="submit" value="Submit"> 
           </form>

Now I’m confused why is it not taking elseif of txtoption3

Any help? Thanks in advance

  • 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-18T14:17:37+00:00Added an answer on June 18, 2026 at 2:17 pm

    That won’t work because, it will be always set. So, use empty();

    elseif(empty($_POST['txtoption3'])) //this is not working
    

    Explanation

    You are posting a form input. When you send it without filling anything, it just sends this value. ""

    An empty string is not equal to null or not set.

    Also, as Peter Szymkowski said, check out the fiddle.

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

Sidebar

Related Questions

I have this PHP code to highlight the Query on search results. if (isset($_REQUEST['k'])){
I found this PHP code in an app I have to modify... $links =
I am using this PHP code: if (isset($_GET['c'])) { $pages = array(home, upload, signup);
I have this php code $jsonArray = array(); $sql = SELECT ID,CLIENT FROM PLD_SERVERS;
I have this PHP code in a loop for every post on the admin
i have this php code and keep on getting errors upon fixing each error.
I have this php code $filename = verbs.php; // http://alylores.x10.mx/vega/verbs2.php $handle = fopen($filename, r);
I have this php code: if ($merchant_rows > 0){ while($r=mysql_fetch_array($get_merchant)){ $merchant_id = $r['merchant_id']; }
I am having problems with this code: <?php $new_value = 'testing'; $con = mysql_connect(localhost,user,pass);
I got this PHP code: // connect to mysql require_once('includes/connect.php'); // include config include('includes/config.php');

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.