0
votes

When the form is submitted, a PHP script, called itgeneratePage.php, should run. It should create HTML elements for the title, top level heading, and body using values from the form. The script should also set CSS properties for the background color and font color of the text using values from the form. Im confused as to why my script is not processing through

<!DOCTYPE HTML> 
        <html>
            <title>webPageGenerator</title>
            <head>
            </head>

            <body>
                <br />
                <h1>Webpage generator</h1>
                <br />
                <form action="itgeneratePage.php" method="post">
                    <p>page name: <input type="text" name="pagename"/></p>
                    <p>background color: <input type="text" name="bgcolor"/></p>
                    <p>font color: <input type="text" name="fontcolor"/></p>
                    <p>your text: <input type="text" name="content"/></p>
                    <p><input type="submit" value="create webpage!"/></p>
                </form>
            </body>

        </html>



        itgeneratePage.php
           <?php    
    //Later configure this in main php config file
    error_reporting(E_ALL);

    //header("Content-type: text/css");
    $bgcolor = $_POST['bgcolor'];
    $color = $_POST['fontcolor'];
    //$dkgreen = '#008400';
?>
<!DOCTYPE html>
<html>
    <head>
        <title><?php echo$_POST['pagename']?></title>
        <style type="text/css">
        body {
            background: <?=$bgcolor?>;
            color: <?=$color?>;
        }       
        </style>
    </head>
    <body>
        <h1><?php echo$_POST['content']?><h1>
        <br /><hr/> 
    </body>
</html>
1
Try with use important after ur color name like background: <?=$bgcolor?>!important; - Maninderpreet Singh

1 Answers

0
votes

You just did small mistake. But don't worry,

Below is the answer :

Just change the css to this:

 body {
        background: <?='#' . $bgcolor?>;
        color: <?='#' . $color?>;
 }