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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T13:08:43+00:00 2026-06-18T13:08:43+00:00

I am having a problem with a checkbox that I need to be part

  • 0

I am having a problem with a checkbox that I need to be part of a stick form, that will be remembered via a session so that the user can navigate through different pages and still have their checkbox selection remember for when they return.

The checkbox is to be clicked by the user if they want to have their delivery details the same as the billing details they entered at the top of the form. No need to worry about how I assign the delivery details to the same as the billing details as I do that on later pages.

Note: Javascript is completely out for this, don’t think its needed anyway but just a heads up :). This is one of those sticky-forms that posts to itself untill all criteria are met($flag == "ok") and then send the user to the next page.

I will now provide what I believe to be the relevant code:

PHP (this section of code may not be relevant but I am including it as I am as can be seen, setting what the final $_SESSION['sameasbilling'] will be before I send the user to the next page(order-confirm.php)

if ($flag == "ok"){
    $sameasbilling = cleanString($_POST['sameasbilling']);
    $_SESSION['sameasbilling'] = $sameasbilling;

    if (!headers_sent()){
        //send user to next page
        header("Location: order-confirm.php");
    }else{
        echo "Not Sent";
    }
}

HTML/PHP

<p>Same as billing address? &nbsp;&nbsp;&nbsp;
<input type="checkbox" id="sameasbilling" name="sameasbilling" value="1" 
<?php 
if (isset($_POST['sameasbilling'])) {
    print ' checked="checked"';
    $_SESSION['sameasbilling'] = "1";
} else {
    $_SESSION['sameasbilling'] = "";
}
?> />

As far as I can see the most important piece of code is above where I try and figure out whether to output checked=’checked’ or not and whether to reset/set the ‘sameasbilling’ session value.

P.S I have been over and over this loads of times and so the IF statement I have in my input element is pretty scruffy, but at the moment does remember your selection when you stay on the same page and receive errors but when you move to the next page and return your selection is not remembered and I’m aware that I do not have any code that would actually do that at all, but I’m hoping someone could suggest how I can achieve that.

  • 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-18T13:08:44+00:00Added an answer on June 18, 2026 at 1:08 pm

    This will only work for the first page when the input box is submitted. To get it to work after returning to the page you need to also check the $_SESSION variable you have set. You could try adding an or section to your if statement such as.

    if (!isset($_POST['sameasbilling']) && $_SESSION['sameasbilling'] != "1") {
         $_SESSION['sameasbilling'] = "";
    } else { 
    print ' checked="checked"';
        $_SESSION['sameasbilling'] = "1";
    
    }
    

    **Edit

    if(isset($_POST['your_submit_button'])){
            if (isset($_POST['sameasbilling'])) {
                print ' checked="checked"';
                $_SESSION['sameasbilling'] = "1";
            } else {
                $_SESSION['sameasbilling'] = "";
            }
        }else if ($_SESSION['sameasbilling'] == "1") {
            print ' checked="checked"';
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having issues with a Linq query that will actually do what I need
I'm having a problem with the checkbox in the array. I'm working on a
I'm having a problem counting checked checkboxes in jQuery that runs counter to every
I have a codeigniter form that contains two checkboxes: <input type=checkbox checked=checked id=box1 name=box1
Hi making a live filter function, but having a problem to send checkbox values
I have a form with a checkbox that's used to filter some search results.
I'm having a problem with knockout checked binding. It seems that change event at
I am having a problem with my jQuery code in that for some reason
Hi guys I am having a problem with Events. I have a checkbox list
I'm having a strange problem with a checkbox on one of my pages. Basically

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.