PHP Practical Slip 10 Q.B

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.

//index.html
<!DOCTYPE html>
<html>
<head>
    <title>Welcome Form</title>
</head>
<body>
    <h2>Enter Your Welcome Message Details</h2>
    <form method="post" action="display.php">
        Font Name: <input type="text" name="font" placeholder="e.g., Arial" required><br><br>
        Background Color: <input type="text" name="bgcolor" placeholder="e.g., yellow" required><br><br>
        Welcome Message: <input type="text" name="message" placeholder="Enter your message" required><br><br>
        <input type="submit" value="Submit">
    </form>
</body>
</html>
//display.php
<?php
// Get values from the form
$font = $_POST['font'];
$bgcolor = $_POST['bgcolor'];
$message = $_POST['message'];
?>

<!DOCTYPE html>
<html>
<head>
    <title>Welcome Message</title>
</head>
<body style="background-color: <?php echo htmlspecialchars($bgcolor); ?>;">
    <h1 style="font-family: <?php echo htmlspecialchars($font); ?>;">
        <?php echo htmlspecialchars($message); ?>
    </h1>
</body>
</html>
Spread the love

Leave a Comment

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

Scroll to Top