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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T10:30:55+00:00 2026-05-19T10:30:55+00:00

I have a page with search form on it and table with search results

  • 0

I have a page with search form on it and table with search results below. In search form i have checkbox “Search in this category”. What i’m doing to check it by default :

if(!isset($_SESSION['inthiscat'])){
    $_SESSION['inthiscat'] = 'on' ;
    $checked = 'checked';
}
$_GET['inthiscat'] = $_SESSION['inthiscat'];

checkbox code : INPUT type=”checkbox” name=”inthiscat”<?=$checked?>.
Link to next page of results index.php?inthiscat=$_GET[‘inthiscat’].
So the problem is when i uncheck “Search in this category” its still checked when i going to next page of results. How to fix it and what i’m doing wrong? Session startet of course.

  • 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-19T10:30:56+00:00Added an answer on May 19, 2026 at 10:30 am

    Firstly, do you really need SESSION variables for this? If you want box to be checked when GET parameter is not specified, you do not need SESSIONs at all.

    Assuming you want to preserve the behaviour in case someone removes the GET parameter:

    <?php
    session_start();
    //......
    //......
    $checked='checked';
    if(isset($_REQUEST['inthiscat'])) {
       // Form input and url GET parameters take precedence
       if($_REQUEST['inthiscat'] != 'checked') { $checked = ''; };
    } else if(isset($_SESSION['inthiscat'])) { 
       // Next, use session variable if it exists
       if($_SESSION['inthiscat'] != 'checked') { $checked = ''; };
    };
    $_SESSION['inthiscat']=$checked;
    ?>
    

    Note:

    1) Assigning values to GET array is not a good practice.

    2) I assume you are using correct syntax for your FORM submit.

    3) IMO, you could remove the SESSION variable as you are explicitly passing as GET parameter in the subsequent urls. Or dont use the GET parameter in urls.

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

Sidebar

Related Questions

I have a form on a page that can filter a results table and
I have a simple JSF application, a search form and results table, and a
On my page I have a search form which generates a table for the
I have a search form and am displaying the results on the same page
I have page with a simple table and advanced search form. I pass List<Customers>
I have a product search page with the form below. The search result is
what I have: a google search form (displayed on all pages) a wordpress page
I have xpath page.search(//table[@class='campaign']//table) which returns two tables. I need to choose only first
I have a search page that if there is results in the list it
I have a search page with the following scenarios listed below. I was told

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.