How to change the web page bgcolor with radio button with $_SESSION

how can I change the web page bgcolor with radio button with $_SESSION?

I know how it works with button but I don’t know how it works with radio button or combo box.
I’m a beginner so please don’t use very professional codes!! This is a school homework!

My code with button:
File 1:
<?php

	session_start();
	
	$_SESSION['color']="yellow";
?>

<body>
	
	<form action="sessioncolor2.php" name="action" method="post">
	  <input type="submit" name="submit" id="submit" value="Submit">
		
	</form>
</body>

File 2:
<?php
session_start();
?>

<body bgcolor="<?php echo $_SESSION['color']?>">
</body>

I mean I want something like those codes!:point_up_2:t2::point_up_2:t2:

I use a smarty templating system, but the principle is just the same.

Here a HTML snippet:
{if $key == 'class'}<div class="{$item}">{/if}{if $key == 'date'}<p>{$item}</p></div>{/if}

Excuse the if statements

Here’s a snippet of php code for my calendar:

    /*
     * Determine if just a regular day or if it's a holiday.
     */
    if (array_key_exists($this->current->format("Y-m-d"), $this->holiday[0])) {
        $this->calendar[$this->z]['class'] = 'item holiday';
        $this->calendar[$this->z]['date'] = $this->current->format("j");
    } else {
        $this->calendar[$this->z]['class'] = 'item date';
        $this->calendar[$this->z]['date'] = $this->current->format("j");
    }

Then in my css I simply do this:

    .today, .holiday {
    background-color: darken( #E6E6FA, 10% );
    color: #fff;
    font-weight: bolder;
    padding: 0.625em;
}
.holiday {
    background-color: rgba(green, 0.6);
}

Excuse the CSS as I use Sass to write my css, so it might look a little strange:

However, it much easier to work with a separate CSS file than doing it inline and bgcolor is really outdated.

@Strider64
Excuse me I don’t understand!
I have to put 4 or 5 radio buttons and when I check one, bgcolor must change!
And I wrote my code with a button and I want a code like that with radio buttons.
I think this is not what my teacher wants!!!

thanks btw :heart:

I don’t see any radio buttons.

Sponsor our Newsletter | Privacy Policy | Terms of Service