BCSL504 Program 8A

Instructions: How to Run?

  • Create a file name called track.php, copy the below code and paste it and save it.
  • Copy track.php file and open XAAMP directory if installed else install it click here
  • There you’ll find a folder named “htdocs”.
  • Inside the “htdocs” folder, paste track.php file.
  • After then open your XAAMP and start the Apache server.
  • Open your favorite browser; we recommend using Google Chrome or Mozilla Firefox.
  • Then, go to the URL “http://localhost/track.php“.

PROGRAM:

<?php
$counterFile = "counter.txt";

if (!file_exists($counterFile)) {
    file_put_contents($counterFile, "0");
}

$currentCount = file_get_contents($counterFile);

$newCount = $currentCount + 1;

file_put_contents($counterFile, $newCount);
?>

<!DOCTYPE html>
<html lang="en">

<head>

    <title>Visitor Counter | vtucode</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            text-align: center;
            margin: 0;
            padding: 0;
            display: flex;
            flex-direction: column;
            justify-content: center;
            height: 100vh;
            background-color: #f4f4f9;
            color: #333;
        }

        .container {
            background: #fff;
            padding: 20px;
            box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
            border-radius: 8px;
            margin: 0 auto;
            width: 60%;
        }

        h1 {
            font-size: 2.5em;
            margin: 0;
        }

        p {
            font-size: 1.2em;
            color: #555;
        }
    </style>
</head>

<body>
    <div class="container">
        <h1>Welcome to Our Website!</h1>
        <p>You are visitor number: <strong><?php echo $newCount; ?></strong></p>
    </div>
</body>

</html>

OUTPUT:

BCSL504 program 8A output

Leave a Reply

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