Wednesday, September 2, 2015

DOM manipulation in php - bad practice - only for getting logic

<?php
    $heading = true;
    $paragraph = true;

    if(isset($_POST['heading'])){
        $heading = true;
        $paragraph = false;
    }

    if(isset($_POST['paragraph'])){
        $paragraph = true;
        $heading = false;
    }

    if(isset($_POST['all'])){
        $paragraph = true;
        $heading = true;
    }

?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title></title>
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css">
    <style>
        p{
            margin-top: 25px;
        }
    </style>
</head>
<body>
<div class="container">
    <div class="row">
        <div class="col-md-4">
            <form method="post" action="">
                <br><br>
                <input type="submit" name="heading" value="heading" class="btn btn-success btn-lg">
                <br><br>
                <input type="submit" name="paragraph" value="paragraph" class="btn btn-success btn-lg">
                <br><br>
                <input type="submit" name="all" value="all" class="btn btn-success btn-lg">
            </form>
        </div>
        <div class="col-md-8">
            <div id="main">
                <?php if($heading) { ?>
                <h1 id="heading">This is heading</h1>
                <?php } if ($paragraph) {?>
                <p id="paragraph">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Aliquid aspernatur assumenda at aut dolor doloremque earum inventore, iure magni nesciunt porro quis veritatis voluptate? Assumenda necessitatibus quidem reprehenderit voluptas? Accusantium? Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ad architecto aut, dicta laudantium nam quam ratione rem sequi ullam vel? Ad animi delectus est libero maxime odit reiciendis, soluta! Harum!Lorem ipsum dolor sit amet, consectetur adipisicing elit. Adipisci alias beatae deleniti dolore excepturi iste iusto maxime nesciunt nihil, nisi obcaecati placeat quae similique sit soluta! Nemo praesentium qui quod!</p>
                <?php } ?>
            </div>
        </div>
    </div>
</div>
</body>
</html>

No comments:

Post a Comment

css snippet for blogger code highlighting

code, .code {     display: block;     background: beige;     padding: 10px;     margin: 8px 15px; }