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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T02:12:05+00:00 2026-06-18T02:12:05+00:00

php code if(isset($_POST[‘txtLocation’])) { $choice_loc = $_POST[txtLocation]; } elseif(!isset($_POST[‘txtLocation’])) { $message = Please select

  • 0

php code

if(isset($_POST['txtLocation']))
{
    $choice_loc = $_POST["txtLocation"];
}
elseif(!isset($_POST['txtLocation']))
{
    $message = "Please select the desired location or click on default";
}
elseif($choice_loc == "txtSetXY")
{
    $x = $_POST["txtXLocation"];
    $y = $_POST["txtYLocation"];
    if($x == "")
    {
        $message = "You forget to enter X location.";
    }
    elseif($y == "")
    {
        $message = "You forget to enter Y location.";
    }
    else
    {
        $choice_loc = $x . "," . $y;
    }
}

This is html form

<div class="formText">
  <input type="radio" name="txtLocation" value="txtSetXY"/> Specify Location<br />
  <div style="padding-left:20px;">
       X: <input type="text" id="locField" name="txtXLocation">
       Y: <input type="text" id="locField" name="txtYLocation">
   </div>
   <input type="radio" name="txtLocation" value="Default" checked="checked"/>Default
</div>

What is the error in logic??

value “default” is entered into database, but when selected value="txtSetXY" radio and entering x and y values in textfields it is not entering into database?

this is my database entering query

$insert = "INSERT INTO dbform (dblocation) VALUES ('{$choice_loc}')";
  • 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-18T02:12:06+00:00Added an answer on June 18, 2026 at 2:12 am

    There is no way your test can enter the third choice :

    elseif($choice_loc == "txtSetXY")
    

    Because

    if(isset($_POST['txtLocation']))
    {
    ...
    }
    elseif(!isset($_POST['txtLocation']))
    {
    ...
    }
    

    covers all the possible paths and could be replaced by

    if(isset($_POST['txtLocation']))
    {
    ...
    }
    else
    {
    ...
    }
    

    where you would have seen that you couldn’t add another test case.

    Maybe you should try to invert the order in your test :

    if(isset($_POST['txtLocation']))
    {
        $choice_loc = $_POST["txtLocation"];
    }
    elseif($choice_loc == "txtSetXY")
    {
        $x = $_POST["txtXLocation"];
        $y = $_POST["txtYLocation"];
        if($x == "")
        {
            $message = "You forget to enter X location.";
        }
        elseif($y == "")
        {
            $message = "You forget to enter Y location.";
        }
        else
        {
            $choice_loc = $x . "," . $y;
        }
    }
    else
    {
        $message = "Please select the desired location or click on default";
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

here is the code <?php session_start(); if(!isset($_SESSION['user_name'])) { header('Location: login.php'); } $conn = mysql_connect(localhost,
At the top of my file I have PHP Code: if (!ISSET ($_POST['submit'])) which
PHP Code: <?php if (isset($_POST['pwsubmitted'])) { $pwsub=$_POST['pass']; if ($pwsub != TEST){ $s=1; $msg =
i need again your help... I have this php code: <? if(isset($_POST['addnews'])){ $type =
This is my php code: if (isset($_POST['data']) && is_array($_POST['data'])) { foreach ($_POST['data'] as $row
Firstly here is my PHP CODE if(!isset($_POST['selection'])){ $missing['selection'] = $required['selection']; } if(empty($missing)) { post2session();
Here is my code in php for sending sms if(isset($_POST['frmType'])&& $_POST['frmType'] == guest_mail){ $from
Following is my search.php code: <?php if(isset($_POST['action']) && $_POST['action'] == Search Question) { $search
I am using this PHP code: if (isset($_GET['c'])) { $pages = array(home, upload, signup);
I have this PHP code to highlight the Query on search results. if (isset($_REQUEST['k'])){

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.