PHP Practical Slip 20 Q.A

Write a PHP script to accept font name, background color, and welcome message
on 1st page. Display the welcome message with the given font and background color on
the next page.

//page1.php
<!DOCTYPE html>
<html>
<head>
    <title>Welcome Page - Input</title>
</head>
<body>

<h2>Enter Display Details</h2>

<form method="post" action="page2.php">
    
    Font Name:
    <select name="font">
        <option value="Arial">Arial</option>
        <option value="Verdana">Verdana</option>
        <option value="Courier New">Courier New</option>
        <option value="Times New Roman">Times New Roman</option>
    </select>
    <br><br>

    Background Color:
    <input type="color" name="bgcolor">
    <br><br>

    Welcome Message:
    <input type="text" name="message">
    <br><br>

    <input type="submit" value="Submit">

</form>

</body>
</html>
//page2.php
<?php

$font = $_POST['font'];
$bgcolor = $_POST['bgcolor'];
$message = $_POST['message'];

?>

<!DOCTYPE html>
<html>
<head>
    <title>Welcome Display</title>
</head>

<body style="background-color: <?php echo $bgcolor; ?>;">

<h1 style="font-family: <?php echo $font; ?>; text-align:center; margin-top:200px;">
    <?php echo $message; ?>
</h1>

</body>
</html>
Spread the love

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top