Click Here to Agree to Our Terms

I agree to the terms




The code used for index.php is below:


<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="../styles.css">
    <title>Checkboxes</title>
</head>
<body>

    <?php

    $message = '';
    $color = '';
    $submit = $_GET['submit'];

    if(isset($submit)){
        // echo print_r($_GET);
        if(array_key_exists('agree', $_GET)){
            $color = "background-color: green;";
            $message = "Checkbox was checked. You have agreed to our terms. You are severely fucked!";
        } else {
            $color = "background-color: darkred;";
            $message = "Checkbox is not checked. You have to agree or you will be punished severely.";
        }
    }
    ?>

    <h2>Click Here to Agree to Our Terms</h2>

    <form action="index.php" method="GET">
        <p><input type="checkbox" name="agree" id="agree">I agree to the terms</p>
        <br>
        <input type="submit" value="Submit" name="submit">
    </form>

    <h3 class="message" style="<?php echo $color; ?>"><?php echo $message; ?></h3>

    <hr>

    <?php
        include('../show_code.php');
        show_code('index.php');
        show_code('process.php');
    ?>
</body>
</html>

The code used for process.php is below: