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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T18:20:44+00:00 2026-05-25T18:20:44+00:00

I am having some difficulty getting the values of two text inputs: <form action=search.php>

  • 0

I am having some difficulty getting the values of two text inputs:

<form action="search.php">
<input type="text" name="q1">
<input type="text" name="q2" >
<input type="submit" name="submit" value="Search" />
</form>

This is the search.php page:

$q1 = @$_GET['q1'];
$q2 = @$_GET['q2'];

if(isset($q1) && isset($q2)) {
$var= "$q1, $q2";
}

if(isset($q1) && empty($q2)) {
$var= "$q1";
}

When both q1 and q2 are filled out and sent, it works perfectly. However, when only the q1 input is filled out and sent (leaving q2 blank), it still creates $var using the the first if-statement — if(isset($q1) && isset($q2) — instead of the second one — if(isset($q1) && empty($q2). Why is this happening?

  • 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-25T18:20:45+00:00Added an answer on May 25, 2026 at 6:20 pm

    You’re setting $q1 and $q2 so isset($q1) and isset($q2) will always return true. Try

    if(isset($_GET['q1']) && isset($_GET['q2'])) {
    

    Or test for an empty value:

    if(empty($q1) && empty($q2)) {
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am having some difficulty writing a function that will search through a directory
I'm having some difficulty getting my cross domain policy to work. I have an
I'm having some difficulty getting this script to execute properly. The create_rss function does
Am having some difficulty getting an Image from a url, and then displaying it
I'm following a tutorial on php, and am having difficulty getting this to work.
I'm having some difficulty getting my django tests to run properly; I'm using nose,
I am having difficulty getting started with interfacing my PHP script to Moodle 2.0
I am having difficulty in getting the session values when I use the Flash
I am having some difficulty getting a pretty simple stored procedure right. Consider the
In one of my unit tests, I am having some difficulty getting a mocked

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.