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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T11:35:10+00:00 2026-06-07T11:35:10+00:00

Before I am told to look at other posts that are similar, please note

  • 0

Before I am told to look at other posts that are similar, please note that I have tried to apply them but to no avail.

I need to clear the variables in the url after a series of if statements are true. I have the following code:

<?php


$_SESSION['passlevel']='0'; 

if ($_SESSION['passlevel'] == '0')

{
if(isset($_GET['box_1_color']))
{
$color=$_GET['box_1_color'];
    if($color == "#800080")
    {
    echo "you have passed step one.";

    $_SESSION['passlevel'] = '1';

    // add something that removes url string



    }
    else 
    {
    echo "you didn't select purple.";

    }   
}
else echo "login with your colorlock passcode.";

}

if ($_SESSION['passlevel'] == '1')

{
if(isset($_GET['box_1_color']))
{
$color=$_GET['box_1_color'];
    if($color == "#DD7500")
    {
    echo "you have passed step two.";
    $_SESSION['passlevel']='2'; 
            // add something that removes url string

    }
    else 
    {
    echo "you didn't select orange.";

    }   
}
else echo "enter remaining colors.";

}


?>

This is for color dependent password that has the background of each of 10 divs change to one of 10 colors after a div is clicked on (note that some of the echoes are only there for now as a method of debugging). The information is sent to the url through multiple forms:

<form> 
<div id="box1" class="box" onclick='this.parentNode.submit()'></div>
<input type='hidden' name='box_1_color' value='<?php echo $box1color ?>'/> 
<input type='hidden' name='name' value='box1color'/> 
</form>

<form>
<div id="box2" class="box" onclick='this.parentNode.submit()'></div>
<input type='hidden' name='box_1_color' value='<?php echo $box2color ?>'/>
<input type='hidden' name='name' value='box2color'/> 
</form>

<form>
<div id="box3" class="box" onclick='this.parentNode.submit()'></div>
<input type='hidden' name='box_1_color' value='<?php echo $box3color ?>'/> 
<input type='hidden' name='name' value='box3color'/> 
</form>

<form>
<div id="box4" class="box" onclick='this.parentNode.submit()'></div>
<input type='hidden' name='box_1_color' value='<?php echo $box4color ?>'/>  
<input type='hidden' name='name' value='box4color'/> 
</form>

<form>
<div id="box5" class="box" onclick='this.parentNode.submit()'></div>
<input type='hidden' name='box_1_color' value='<?php echo $box5color ?>'/>  
<input type='hidden' name='name' value='box5color'/> 
</form>

<form>
<div id="box6" class="box" onclick='this.parentNode.submit()'></div>
<input type='hidden' name='box_1_color' value='<?php echo $box6color ?>'/> 
<input type='hidden' name='name' value='box6color'/> 
</form>

<form>
<div id="box7" class="box" onclick='this.parentNode.submit()'></div>
<input type='hidden' name='box_1_color' value='<?php echo $box7color ?>'/> 
<input type='hidden' name='name' value='box7color'/> 
</form>

<form>
<div id="box8" class="box" onclick='this.parentNode.submit()'></div>
<input type='hidden' name='box_1_color' value='<?php echo $box8color ?>'/>
<input type='hidden' name='name' value='box8color'/>
</form>

<form>
<div id="box9" class="box" onclick='this.parentNode.submit()'></div>
<input type='hidden' name='box_1_color' value='<?php echo $box9color ?>'/>
<input type='hidden' name='name' value='box9color'/>
</form>

<form>
<div id="box10" class="box" onclick='this.parentNode.submit()'></div>
<input type='hidden' name='box_1_color' value='<?php echo $box10color ?>'/> 
<input type='hidden' name='name' value='box10color'/> 
</form> 

An example of the url after one of the colors (purple) is selected:
http://localhost/colorlock/index.php?box_1_color=%23800080&name=box9color

So I want to remove the ?box_1_color=%23800080&name=box9color part. How could i remove it where the code says “// add something that removes url string” so that when the next block of code is initiated it doesnt run immediately with the same color code in the url before a user can select their next color?

I hope my question is clear (i understand that it a confusing) and i hope that it is answerable. Thank you.

  • 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-07T11:35:12+00:00Added an answer on June 7, 2026 at 11:35 am

    You need to do one/some of 3 things:

    1. Use POST. This is a good idea but it would still be best combined with…
    2. Redirect to the same page without the URL arguments after processing the form.
    3. Use ajax to process the user input.

    The easiest of these to integrate with your existing code is probably a combination of 1 and 2. To do this, add these lines where your comment is:

    header("HTTP/1.1 303 See Other");
    header("Location: http://{$_SERVER['HTTP_HOST']}{$_SERVER['PHP_SELF']}");
    exit;
    

    …and change all the <form> elements in your HTML so that they read:

    <form method="post">
    

    …and obviously change all occurrences of $_GET in your PHP code to $_POST

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

Sidebar

Related Questions

I have previously been told that I should always use Randomize() before I use
I have been told to use log4j for my logging project,but before using log4j,
I have posted about this before but never in this regard so please take
I have never programmed in visual basic before and my boss just told me
(Before I start, yes I have asked a similar question before; unfortunately due to
Before saying anything I have to say that, albeit I'm an experienced programmer in
I can't see anything on here but I do remember being told that If
I've been told that javascript variables should all come before they are used in
I have been here before, asking for a mapping library that could store objects
I asked this question before but some of the experts told me to add

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.