Beginners To Experts


The site is under development.

PHP Real World Projects

Option 1: Run with XAMPP (Windows/Linux/macOS)

  1. Install XAMPP
    Download from: https://www.apachefriends.org
  2. Start the server
    Open the XAMPP Control Panel
    Start Apache (and MySQL if needed)
  3. Place your PHP file
    Copy your .php file to the htdocs folder:
    • On Windows: C:\xampp\htdocs\yourproject\file.php
    • On macOS/Linux: /Applications/XAMPP/htdocs/yourproject/file.php
  4. Open your browser
    Visit:
    http://localhost/yourproject/file.php

Option 2: Use PHP’s Built-in Server (Quick Test)

  1. Install PHP
    Already included on macOS and most Linux distros
    On Windows: https://windows.php.net/download
  2. Navigate to your project folder
    Open terminal/command prompt and run:
    cd path/to/your/php/project
  3. Run the built-in server
    php -S localhost:8000
  4. Open in browser
    http://localhost:8000/yourfile.php

Option 3: Use an Online PHP Editor (No Installation)

Use services like:

Paste your PHP code and run it online.


<?php
// Check if the form was submitted
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
    // Collect form data
    $name = $_POST['name'];
    $email = $_POST['email'];
    $message = $_POST['message'];

    // Display submitted data
    echo "Thank you, $name. We have received your message.";
}
?>

<form method="post">
  Name: <input type="text" name="name"><br>
  Email: <input type="email" name="email"><br>
  Message: <textarea name="message"></textarea><br>
  <input type="submit" value="Send">
</form>
      
Expected Output: User fills form, PHP displays: "Thank you, John. We have received your message."


<?php
// Save guest message to file
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
    $guest = $_POST['guest'];
    $msg = $_POST['message'];
    file_put_contents('guestbook.txt', "$guest: $msg\n", FILE_APPEND);
}
?>

<form method="post">
  Name: <input type="text" name="guest"><br>
  Message: <textarea name="message"></textarea><br>
  <input type="submit" value="Sign Guestbook">
</form>
      
Expected Output: New guest entry saved to `guestbook.txt` file.


<?php
// Handle uploaded file
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_FILES['file'])) {
    move_uploaded_file($_FILES['file']['tmp_name'], 'uploads/' . $_FILES['file']['name']);
    echo "File uploaded successfully!";
}
?>

<form method="post" enctype="multipart/form-data">
  Choose file: <input type="file" name="file"><br>
  <input type="submit" value="Upload">
</form>
      
Expected Output: Selected file is stored in `uploads/` and success message is shown.


<?php
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
    $a = $_POST['num1'];
    $b = $_POST['num2'];
    $op = $_POST['operation'];

    if ($op == 'add') {
        echo "Result: " . ($a + $b);
    } else {
        echo "Result: " . ($a - $b);
    }
}
?>

<form method="post">
  Number 1: <input type="number" name="num1"><br>
  Number 2: <input type="number" name="num2"><br>
  Operation:
  <select name="operation">
    <option value="add">Add</option>
    <option value="sub">Subtract</option>
  </select><br>
  <input type="submit" value="Calculate">
</form>
      
Expected Output: Displays: “Result: 15” (if inputs are 10 and 5 with "Add" selected).


<?php
// Log user IP address to a file
$ip = $_SERVER['REMOTE_ADDR'];
file_put_contents('ips.txt', "$ip\n", FILE_APPEND);
echo "Your IP address has been logged.";
?>
      
Expected Output: Outputs message and logs IP to `ips.txt` file.

<?php
$price = $taxRate = $total = "";

if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $price = floatval($_POST["price"]);
    $taxRate = floatval($_POST["tax"]);
    $total = $price + ($price * ($taxRate / 100));
}
?>

<form method="POST" action="">
    Base Price: <input type="number" name="price" step="0.01" required><br>
    Tax Rate (%): <input type="number" name="tax" step="0.01" required><br>
    <input type="submit" value="Calculate Total">
</form>

<?php if ($total !== ""): ?>
    <p>Total Price (with tax): <strong><?= number_format($total, 2) ?></strong></p>
<?php endif; ?>

<?php
session_start();
if (!isset($_SESSION['tasks'])) {
    $_SESSION['tasks'] = [];
}

if ($_SERVER["REQUEST_METHOD"] == "POST" && !empty($_POST['task'])) {
    $_SESSION['tasks'][] = htmlspecialchars($_POST['task']);
}

if (isset($_GET['clear'])) {
    $_SESSION['tasks'] = [];
}
?>

<h3>Task List</h3>
<form method="POST" action="">
    <input type="text" name="task" placeholder="Enter new task">
    <input type="submit" value="Add Task">
</form>

<ul>
<?php foreach ($_SESSION['tasks'] as $task): ?>
    <li><?= $task ?></li>
<?php endforeach; ?>
</ul>

<a href="?clear=true">Clear Tasks</a>

<?php
$usd = $eur = "";

if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $usd = floatval($_POST["usd"]);
    $exchangeRate = 0.91; // Example rate: 1 USD = 0.91 EUR
    $eur = $usd * $exchangeRate;
}
?>

<form method="POST" action="">
    USD Amount: <input type="number" name="usd" step="0.01" required><br>
    <input type="submit" value="Convert to EUR">
</form>

<?php if ($eur !== ""): ?>
    <p>Equivalent in EUR: <strong><?= number_format($eur, 2) ?></strong></p>
<?php endif; ?>

<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $name = htmlspecialchars($_POST["name"]);
    $event = htmlspecialchars($_POST["event"]);
    echo "Thanks, $name! You are registered for: $event";
}
?>

<form method="POST" action="">
  Name: <input type="text" name="name" required><br>
  Event: 
  <select name="event">
    <option value="PHP Workshop">PHP Workshop</option>
    <option value="Laravel Bootcamp">Laravel Bootcamp</option>
  </select><br>
  <input type="submit" value="Register">
</form>

<?php
$inventory = [
    "Laptop" => 4,
    "Mouse" => 20,
    "Keyboard" => 10
];

if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $product = $_POST["product"];
    if (isset($inventory[$product])) {
        echo "Stock available for $product: " . $inventory[$product];
    } else {
        echo "$product is not in stock.";
    }
}
?>

<form method="POST" action="">
  Check product:
  <select name="product">
    <option>Laptop</option>
    <option>Mouse</option>
    <option>Keyboard</option>
  </select><br>
  <input type="submit" value="Check Stock">
</form>

<?php
$bmi = "";

if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $weight = floatval($_POST["weight"]);
    $height = floatval($_POST["height"]);
    if ($height > 0) {
        $bmi = $weight / ($height * $height);
    }
}
?>

<form method="POST" action="">
  Weight (kg): <input type="number" name="weight" step="0.1" required><br>
  Height (m): <input type="number" name="height" step="0.01" required><br>
  <input type="submit" value="Calculate BMI">
</form>

<?php if ($bmi): ?>
  <p>Your BMI is: <strong><?= number_format($bmi, 2) ?></strong></p>
<?php endif; ?>

<?php
$bmi = "";
$category = "";
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $weight = floatval($_POST["weight"]);
    $height = floatval($_POST["height"]) / 100; // convert cm to meters
    if ($height > 0) {
        $bmi = $weight / ($height * $height);
        if ($bmi < 18.5) {
            $category = "Underweight";
        } elseif ($bmi < 25) {
            $category = "Normal weight";
        } elseif ($bmi < 30) {
            $category = "Overweight";
        } else {
            $category = "Obesity";
        }
    }
}
?>

<form method="POST">
  Weight (kg): <input type="number" name="weight" step="0.1" required><br>
  Height (cm): <input type="number" name="height" step="0.1" required><br>
  <input type="submit" value="Calculate BMI">
</form>

<?php if ($bmi): ?>
  <p>Your BMI is: <strong><?= number_format($bmi, 2) ?></strong> - <?= $category ?></p>
<?php endif; ?>

<?php
$result = "";
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $celsius = floatval($_POST["celsius"]);
    $fahrenheit = ($celsius * 9/5) + 32;
    $result = "$celsius °C = $fahrenheit °F";
}
?>

<form method="POST">
  Celsius: <input type="number" name="celsius" step="0.1" required><br>
  <input type="submit" value="Convert">
</form>

<?php if ($result): ?>
  <p><?= $result ?></p>
<?php endif; ?>

<?php
$monthly = "";
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $amount = floatval($_POST["amount"]);
    $years = intval($_POST["years"]);
    $rate = floatval($_POST["rate"]) / 100 / 12;
    $n = $years * 12;
    if ($rate > 0) {
        $monthly = $amount * $rate / (1 - pow(1 + $rate, -$n));
    } else {
        $monthly = $amount / $n;
    }
}
?>

<form method="POST">
  Loan Amount: <input type="number" name="amount" required><br>
  Years: <input type="number" name="years" required><br>
  Interest Rate (%): <input type="number" name="rate" step="0.01" required><br>
  <input type="submit" value="Calculate Payment">
</form>

<?php if ($monthly): ?>
  <p>Monthly Payment: <strong>$<?= number_format($monthly, 2) ?></strong></p>
<?php endif; ?>

<?php
$finalPrice = "";
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $price = floatval($_POST["price"]);
    $discount = floatval($_POST["discount"]);
    $finalPrice = $price - ($price * $discount / 100);
}
?>

<form method="POST">
  Original Price: <input type="number" name="price" required><br>
  Discount (%): <input type="number" name="discount" step="0.1" required><br>
  <input type="submit" value="Calculate Final Price">
</form>

<?php if ($finalPrice !== ""): ?>
  <p>Discounted Price: <strong>$<?= number_format($finalPrice, 2) ?></strong></p>
<?php endif; ?>

<?php
$quotes = [
  "The best way to get started is to quit talking and begin doing.",
  "Don’t let yesterday take up too much of today.",
  "It’s not whether you get knocked down, it’s whether you get up.",
  "If you are working on something exciting, it will keep you motivated."
];
$randomQuote = $quotes[array_rand($quotes)];
?>

<p><strong>Quote of the Moment:</strong></p>
<blockquote><?= $randomQuote ?></blockquote>

<?php
session_start();
if (!isset($_SESSION["todos"])) {
    $_SESSION["todos"] = [];
}
if ($_SERVER["REQUEST_METHOD"] == "POST" && !empty($_POST["task"])) {
    $_SESSION["todos"][] = htmlspecialchars($_POST["task"]);
}
?>

<form method="POST">
  Add Task: <input type="text" name="task" required>
  <input type="submit" value="Add">
</form>

<ul>
<?php foreach ($_SESSION["todos"] as $item): ?>
  <li><?= $item ?></li>
<?php endforeach; ?>
</ul>

<?php
$result = "";
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $amount = floatval($_POST["amount"]);
    $currency = $_POST["currency"];
    $rates = [
        "INR" => 83.10,
        "EUR" => 0.92,
        "GBP" => 0.79
    ];
    if (isset($rates[$currency])) {
        $converted = $amount * $rates[$currency];
        $result = "$amount USD = " . number_format($converted, 2) . " $currency";
    }
}
?>

<form method="post">
  Amount in USD: <input type="number" name="amount" step="0.01" required>
  Convert to:
  <select name="currency">
    <option value="INR">INR</option>
    <option value="EUR">EUR</option>
    <option value="GBP">GBP</option>
  </select>
  <input type="submit" value="Convert">
</form>

<?php if ($result): ?>
  <p><strong><?= $result ?></strong></p>
<?php endif; ?>

<?php
$quotes = [
  "The only limit to our realization of tomorrow is our doubts of today.",
  "Success is not final, failure is not fatal: it is the courage to continue that counts.",
  "Do not wait to strike till the iron is hot, but make it hot by striking."
];
$random_quote = $quotes[array_rand($quotes)];
?>

<p><strong>Random Quote:</strong></p>
<blockquote><?= $random_quote ?></blockquote>

<?php
$final_price = "";
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $price = floatval($_POST["price"]);
    $discount = floatval($_POST["discount"]);
    $final_price = $price - ($price * $discount / 100);
}
?>

<form method="post">
  Original Price: <input type="number" name="price" required><br>
  Discount (%): <input type="number" name="discount" required><br>
  <input type="submit" value="Calculate">
</form>

<?php if ($final_price): ?>
  <p>Final Price: <strong><?= number_format($final_price, 2) ?></strong></p>
<?php endif; ?>

<?php
$messages = [
  "You are capable of amazing things.",
  "Keep pushing forward!",
  "Every day is a new opportunity."
];
$index = date("z") % count($messages);
?>

<p><strong>Today's Message:</strong> <?= $messages[$index] ?></p>

<?php
$result = "";
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $year = intval($_POST["year"]);
    if (($year % 4 == 0 && $year % 100 != 0) || ($year % 400 == 0)) {
        $result = "$year is a Leap Year.";
    } else {
        $result = "$year is NOT a Leap Year.";
    }
}
?>

<form method="post">
  Enter Year: <input type="number" name="year" required>
  <input type="submit" value="Check">
</form>

<?php if ($result): ?>
  <p><strong><?= $result ?></strong></p>
<?php endif; ?>

<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $name = $_POST["name"];
    $email = $_POST["email"];
    $password = $_POST["password"];
    // Insert into database or process the data
    echo "Registration successful for $name!";
}
?>

<form method="post">
    Name: <input type="text" name="name" required><br>
    Email: <input type="email" name="email" required><br>
    Password: <input type="password" name="password" required><br>
    <input type="submit" value="Register">
</form>

<form method="post">
    Password: <input type="password" name="password" id="password" required><br>
    <input type="submit" value="Check Strength">
</form>

<script>
document.getElementById("password").addEventListener("input", function() {
    var password = this.value;
    var strength = "Weak";
    if (password.length >= 8) {
        strength = "Medium";
    }
    if (password.length >= 12) {
        strength = "Strong";
    }
    alert("Password strength: " + strength);
});
</script>

<?php
if ($_SERVER["REQUEST_METHOD"] == "POST" && isset($_POST["task"])) {
    $task = $_POST["task"];
    // Save task in a database or file
    echo "Task '$task' added successfully!";
}
?>

<form method="post">
    Task: <input type="text" name="task" required><br>
    <input type="submit" value="Add Task">
</form>

<!-- Display tasks here if any -->

<form method="post">
    Date of Birth: <input type="date" name="dob" required><br>
    <input type="submit" value="Calculate Age">
</form>

<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $dob = $_POST["dob"];
    $dobDate = new DateTime($dob);
    $now = new DateTime();
    $age = $dobDate->diff($now)->y;
    echo "You are $age years old.";
}
?>

<form method="post">
    Weight (kg): <input type="number" name="weight" required><br>
    Height (m): <input type="number" step="0.01" name="height" required><br>
    <input type="submit" value="Calculate BMI">
</form>

<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $weight = $_POST["weight"];
    $height = $_POST["height"];
    $bmi = $weight / ($height * $height);
    echo "Your BMI is " . number_format($bmi, 2);
}
?>

<form method="post">
    Name: <input type="text" name="name" required><br>
    Email: <input type="email" name="email" required><br>
    Message: <textarea name="message" required></textarea><br>
    <input type="submit" value="Send Message">
</form>

<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $name = $_POST["name"];
    $email = $_POST["email"];
    $message = $_POST["message"];
    // Process the contact form
    echo "Message from $name: $message";
}
?>

<form method="post">
    Username: <input type="text" name="username" required><br>
    Password: <input type="password" name="password" required><br>
    <input type="submit" value="Login">
</form>

<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $username = $_POST["username"];
    $password = $_POST["password"];
    // Simple authentication check
    if ($username == "admin" && $password == "password123") {
        echo "Login successful!";
    } else {
        echo "Invalid username or password.";
    }
}
?>

<form method="post">
    Vote: <input type="radio" name="vote" value="Option 1" required> Option 1<br>
    <input type="radio" name="vote" value="Option 2"> Option 2<br>
    <input type="radio" name="vote" value="Option 3"> Option 3<br>
    <input type="submit" value="Submit Vote">
</form>

<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $vote = $_POST["vote"];
    echo "You voted for: $vote";
}
?>

<form method="post" enctype="multipart/form-data">
    Select file to upload: <input type="file" name="fileToUpload" required><br>
    <input type="submit" value="Upload File">
</form>

<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $target_dir = "uploads/";
    $target_file = $target_dir . basename($_FILES["fileToUpload"]["name"]);
    if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file)) {
        echo "The file ". basename( $_FILES["fileToUpload"]["name"]). " has been uploaded.";
    } else {
        echo "Sorry, there was an error uploading your file.";
    }
}
?>

<form method="get">
    Search: <input type="text" name="query" required><br>
    <input type="submit" value="Search">
</form>

<?php
if ($_SERVER["REQUEST_METHOD"] == "GET" && isset($_GET["query"])) {
    $query = $_GET["query"];
    // Simulate a simple search (in a real app, you'd search a database)
    echo "You searched for: $query";
}
?>

<form method="post">
    Email: <input type="email" name="email" required><br>
    <input type="submit" value="Subscribe">
</form>

<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $email = $_POST["email"];
    // Add email to a subscription list
    echo "Thank you for subscribing!";
}
?>

<form method="post">
    Email: <input type="email" name="email" required><br>
    <input type="submit" value="Subscribe">
</form>

<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $email = $_POST["email"];
    // Add email to a subscription list
    echo "Thank you for subscribing!";
}
?>

<form method="post" enctype="multipart/form-data">
    Select image to upload: <input type="file" name="imageToUpload" required><br>
    <input type="submit" value="Upload Image">
</form>

<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $target_dir = "images/";
    $target_file = $target_dir . basename($_FILES["imageToUpload"]["name"]);
    if (move_uploaded_file($_FILES["imageToUpload"]["tmp_name"], $target_file)) {
        echo "The image ". basename( $_FILES["imageToUpload"]["name"]). " has been uploaded.";
    } else {
        echo "Sorry, there was an error uploading your image.";
    }
}
?>

<form method="get">
    <input type="submit" name="download" value="Download File">
</form>

<?php
if (isset($_GET["download"])) {
    $file = "path/to/your/file.zip"; // File to download
    header("Content-Description: File Transfer");
    header("Content-Type: application/octet-stream");
    header("Content-Disposition: attachment; filename=" . basename($file));
    header("Content-Length: " . filesize($file));
    readfile($file);
}
?>

<form method="post">
    Username: <input type="text" name="username" required><br>
    Password: <input type="password" name="password" required><br>
    Email: <input type="email" name="email" required><br>
    <input type="submit" value="Register">
</form>

<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $username = $_POST["username"];
    $password = $_POST["password"];
    $email = $_POST["email"];
    // Save the user data (to a database or file)
    echo "User registered successfully!";
}
?>

<form method="post">
    Username: <input type="text" name="username" required><br>
    Password: <input type="password" name="password" required><br>
    <input type="submit" value="Login">
</form>

<?php
session_start();

if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $username = $_POST["username"];
    $password = $_POST["password"];
    // Dummy authentication
    if ($username == "admin" && $password == "password") {
        $_SESSION["username"] = $username;
        echo "Logged in successfully!";
    } else {
        echo "Invalid credentials!";
    }
}
?>

<form method="post">
    <input type="submit" name="logout" value="Logout">
</form>

<?php
session_start();

if (isset($_POST["logout"])) {
    session_unset();
    session_destroy();
    echo "Logged out successfully!";
}
?>

<form method="post">
    Email: <input type="email" name="email" required><br>
    <input type="submit" value="Send Reset Link">
</form>

<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $email = $_POST["email"];
    // Simulate sending a reset link
    echo "A password reset link has been sent to $email!";
}
?>

<?php
$dir = "files/";
$files = scandir($dir);

foreach ($files as $file) {
    if ($file != "." && $file != "..") {
        echo "<a href='$dir$file'>$file</a><br>";
    }
}
?>

<form method="post">
    Name: <input type="text" name="name" required><br>
    Feedback: <textarea name="feedback" required></textarea><br>
    <input type="submit" value="Submit Feedback">
</form>

<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $name = $_POST["name"];
    $feedback = $_POST["feedback"];
    echo "Thank you for your feedback, $name!";
}
?>

<div class="slider">
    <img src="image1.jpg" alt="Image 1">
    <img src="image2.jpg" alt="Image 2">
    <img src="image3.jpg" alt="Image 3">
</div>

<style>
.slider img {
    width: 100%;
    display: none;
}
.slider img:first-child {
    display: block;
}
</style>

<script>
let images = document.querySelectorAll('.slider img');
let currentIndex = 0;
setInterval(() => {
    images[currentIndex].style.display = "none";
    currentIndex = (currentIndex + 1) % images.length;
    images[currentIndex].style.display = "block";
}, 3000);
</script>

<button id="loadButton">Load Content</button>
<div id="content"></div>

<script>
document.getElementById("loadButton").addEventListener("click", function() {
    let xhr = new XMLHttpRequest();
    xhr.open("GET", "content.txt", true);
    xhr.onload = function() {
        if (xhr.status === 200) {
            document.getElementById("content").innerHTML = xhr.responseText;
        }
    };
    xhr.send();
});
</script>

<form method="post">
    Name: <input type="text" name="name" required><br>
    Email: <input type="email" name="email" required><br>
    Message: <textarea name="message" required></textarea><br>
    <input type="submit" value="Send Message">
</form>

<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $name = $_POST["name"];
    $email = $_POST["email"];
    $message = $_POST["message"];
    
    mail("recipient@example.com", "Contact Us Message", $message, "From: $email");
    echo "Your message has been sent!";
}
?>

<form method="post">
    Task: <input type="text" name="task" required><br>
    <input type="submit" value="Add Task">
</form>

<?php
$tasks = [];
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $task = $_POST["task"];
    $tasks[] = $task;
}

foreach ($tasks as $task) {
    echo "<li>$task</li>";
}
?>

<form method="post">
    What is your favorite color?<br>
    <input type="radio" name="color" value="Red"> Red<br>
    <input type="radio" name="color" value="Blue"> Blue<br>
    <input type="radio" name="color" value="Green"> Green<br>
    <input type="submit" value="Vote">
</form>

<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $color = $_POST["color"];
    echo "Your favorite color is $color!";
}
?>

<form method="get">
    Enter City: <input type="text" name="city" required><br>
    <input type="submit" value="Get Weather">
</form>

<?php
if (isset($_GET["city"])) {
    $city = $_GET["city"];
    $weather = file_get_contents("http://api.weatherstack.com/current?access_key=YOUR_ACCESS_KEY&query=$city");
    echo "Weather info: $weather";
}
?>

<form method="post" enctype="multipart/form-data">
    Select Image: <input type="file" id="image" name="image" onchange="previewImage(event)"><br>
    <input type="submit" value="Upload Image">
</form>

<img id="preview" src="" alt="Image Preview" style="width: 200px;"/>

<script>
function previewImage(event) {
    let reader = new FileReader();
    reader.onload = function() {
        let preview = document.getElementById("preview");
        preview.src = reader.result;
    };
    reader.readAsDataURL(event.target.files[0]);
}
</script>

<form method="post">
    Title: <input type="text" name="title" required><br>
    Content: <textarea name="content" required></textarea><br>
    <input type="submit" value="Publish Post">
</form>

<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $title = $_POST["title"];
    $content = $_POST["content"];
    echo "<h2>$title</h2><p>$content</p>";
}
?>

<form method="post">
    Name: <input type="text" name="name" required><br>
    Email: <input type="email" name="email" required><br>
    <input type="submit" value="Subscribe">
</form>

<?php
$servername = "localhost";
$username = "username";
$password = "password";
$dbname = "newsletter";

$conn = new mysqli($servername, $username, $password, $dbname);

if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $name = $_POST["name"];
    $email = $_POST["email"];
    $sql = "INSERT INTO subscribers (name, email) VALUES ('$name', '$email')";
    if ($conn->query($sql) === TRUE) {
        echo "You have successfully subscribed to the newsletter!";
    } else {
        echo "Error: " . $conn->error;
    }
}
$conn->close();
?>

<form method="post">
    Username: <input type="text" name="username" required><br>
    Password: <input type="password" name="password" required><br>
    Confirm Password: <input type="password" name="conf_password" required><br>
    <input type="submit" value="Register">
</form>

<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $username = $_POST["username"];
    $password = $_POST["password"];
    $conf_password = $_POST["conf_password"];
    
    if ($password === $conf_password) {
        echo "Registration successful!";
    } else {
        echo "Passwords do not match!";
    }
}
?>

<div id="clock"></div>

<script>
function updateClock() {
    let now = new Date();
    let hours = now.getHours().toString().padStart(2, '0');
    let minutes = now.getMinutes().toString().padStart(2, '0');
    let seconds = now.getSeconds().toString().padStart(2, '0');
    document.getElementById("clock").innerHTML = hours + ":" + minutes + ":" + seconds;
}
setInterval(updateClock, 1000);
updateClock();
</script>

<form method="post">
    Question: What is 2 + 2?<br>
    <input type="radio" name="answer" value="3"> 3<br>
    <input type="radio" name="answer" value="4"> 4<br>
    <input type="radio" name="answer" value="5"> 5<br>
    <input type="submit" value="Submit">
</form>

<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $answer = $_POST["answer"];
    if ($answer == "4") {
        echo "Correct answer!";
    } else {
        echo "Wrong answer, try again!";
    }
}
?>

<form method="post">
    Item Name: <input type="text" name="item_name" required><br>
    Price: <input type="number" name="price" required><br>
    <input type="submit" value="Add Item">
</form>

<?php
$servername = "localhost";
$username = "username";
$password = "password";
$dbname = "shop";

$conn = new mysqli($servername, $username, $password, $dbname);

if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $item_name = $_POST["item_name"];
    $price = $_POST["price"];
    $sql = "INSERT INTO items (item_name, price) VALUES ('$item_name', '$price')";
    if ($conn->query($sql) === TRUE) {
        echo "Item added!";
    } else {
        echo "Error: " . $conn->error;
    }
}

$sql = "SELECT * FROM items";
$result = $conn->query($sql);

if ($result->num_rows > 0) {
    while($row = $result->fetch_assoc()) {
        echo "<div>{$row['item_name']} - {$row['price']}</div>";
    }
}
$conn->close();
?>

<form method="post">
    Username: <input type="text" name="username" required><br>
    Password: <input type="password" name="password" required><br>
    <input type="submit" value="Login">
</form>

<?php
session_start();

if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $_SESSION["username"] = $_POST["username"];
    $_SESSION["password"] = $_POST["password"];
    echo "Logged in as: " . $_SESSION["username"];
}
?>

<form method="post">
    Amount: <input type="number" name="amount" required><br>
    Convert from: <select name="from_currency">
        <option value="USD">USD</option>
        <option value="EUR">EUR</option>
    </select><br>
    Convert to: <select name="to_currency">
        <option value="USD">USD</option>
        <option value="EUR">EUR</option>
    </select><br>
    <input type="submit" value="Convert">
</form>

<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $amount = $_POST["amount"];
    $from_currency = $_POST["from_currency"];
    $to_currency = $_POST["to_currency"];
    
    if ($from_currency == "USD" && $to_currency == "EUR") {
        $rate = 0.85;
    } elseif ($from_currency == "EUR" && $to_currency == "USD") {
        $rate = 1.18;
    }
    
    $converted_amount = $amount * $rate;
    echo "Converted amount: " . $converted_amount;
}
?>

<form method="get">
    City: <input type="text" name="city" required><br>
    <input type="submit" value="Get Weather">
</form>

<?php
if (isset($_GET['city'])) {
    $city = urlencode($_GET['city']);
    $apiKey = "your_api_key";
    $url = "https://api.openweathermap.org/data/2.5/weather?q=$city&appid=$apiKey";
    $response = file_get_contents($url);
    $data = json_decode($response);
    
    if ($data->cod == 200) {
        echo "Weather in $city: " . $data->weather[0]->description . "<br>";
        echo "Temperature: " . $data->main->temp . "°C<br>";
    } else {
        echo "City not found!";
    }
}
?>

<form method="get">
    Amount: <input type="number" name="amount" required><br>
    From Currency: <input type="text" name="from_currency" required><br>
    To Currency: <input type="text" name="to_currency" required><br>
    <input type="submit" value="Convert">
</form>

<?php
if (isset($_GET['amount']) && isset($_GET['from_currency']) && isset($_GET['to_currency'])) {
    $amount = $_GET['amount'];
    $from_currency = $_GET['from_currency'];
    $to_currency = $_GET['to_currency'];
    $url = "https://api.exchangerate-api.com/v4/latest/$from_currency";
    $response = file_get_contents($url);
    $data = json_decode($response);
    
    if (isset($data->rates->$to_currency)) {
        $converted_amount = $amount * $data->rates->$to_currency;
        echo "$amount $from_currency = $converted_amount $to_currency";
    } else {
        echo "Currency not found!";
    }
}
?>

<form method="post">
    Task: <input type="text" name="task" required><br>
    <input type="submit" value="Add Task">
</form>

<?php
session_start();
if (!isset($_SESSION['tasks'])) {
    $_SESSION['tasks'] = [];
}

if (isset($_POST['task'])) {
    $task = $_POST['task'];
    $_SESSION['tasks'][] = $task;
}

if (count($_SESSION['tasks']) > 0) {
    echo "<ul>";
    foreach ($_SESSION['tasks'] as $task) {
        echo "<li>$task</li>";
    }
    echo "</ul>";
} else {
    echo "No tasks yet!";
}
?>

<form method="get">
    Select File: <input type="file" name="file"><br>
    <input type="submit" value="Download">
</form>

<?php
if (isset($_GET['file'])) {
    $file = $_GET['file'];
    if (file_exists($file)) {
        header('Content-Description: File Transfer');
        header('Content-Type: application/octet-stream');
        header('Content-Disposition: attachment; filename="' . basename($file) . '"');
        header('Content-Length: ' . filesize($file));
        readfile($file);
        exit;
    } else {
        echo "File not found!";
    }
}
?>

<form method="post" enctype="multipart/form-data">
    Select image to upload: <input type="file" name="fileToUpload" id="fileToUpload"><br>
    <input type="submit" value="Upload Image" name="submit">
</form>

<?php
if (isset($_POST['submit'])) {
    $target_dir = "uploads/";
    $target_file = $target_dir . basename($_FILES["fileToUpload"]["name"]);
    if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file)) {
        echo "The file ". basename($_FILES["fileToUpload"]["name"]). " has been uploaded.";
    } else {
        echo "Sorry, there was an error uploading your file.";
    }
}
?>

<form method="post">
    Username: <input type="text" name="username" required><br>
    Password: <input type="password" name="password" required><br>
    Email: <input type="email" name="email" required><br>
    <input type="submit" value="Register">
</form>

<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $servername = "localhost";
    $username = "root";
    $password = "";
    $dbname = "users";

    $conn = new mysqli($servername, $username, $password, $dbname);

    if ($conn->connect_error) {
        die("Connection failed: " . $conn->connect_error);
    }

    $user = $_POST['username'];
    $pass = $_POST['password'];
    $email = $_POST['email'];

    $sql = "INSERT INTO users (username, password, email) VALUES ('$user', '$pass', '$email')";
    if ($conn->query($sql) === TRUE) {
        echo "Registration successful!";
    } else {
        echo "Error: " . $conn->error;
    }
    $conn->close();
}
?>

<form method="post">
    Email: <input type="email" name="email" required><br>
    <input type="submit" value="Verify Email">
</form>

<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $email = $_POST['email'];
    $verification_code = rand(100000, 999999);
    $subject = "Email Verification Code";
    $message = "Your verification code is: $verification_code";
    $headers = "From: no-reply@example.com";

    if (mail($email, $subject, $message, $headers)) {
        echo "A verification code has been sent to your email!";
    } else {
        echo "Failed to send verification code.";
    }
}
?>

<form method="post">
    Email: <input type="email" name="email" required><br>
    New Password: <input type="password" name="new_password" required><br>
    <input type="submit" value="Reset Password">
</form>

<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $email = $_POST['email'];
    $new_password = $_POST['new_password'];
    
    $servername = "localhost";
    $username = "root";
    $password = "";
    $dbname = "users";

    $conn = new mysqli($servername, $username, $password, $dbname);

    if ($conn->connect_error) {
        die("Connection failed: " . $conn->connect_error);
    }

    $sql = "UPDATE users SET password='$new_password' WHERE email='$email'";
    if ($conn->query($sql) === TRUE) {
        echo "Password has been successfully reset!";
    } else {
        echo "Error: " . $conn->error;
    }
    $conn->close();
}
?>

<form method="post">
    Name: <input type="text" name="name" required><br>
    Email: <input type="email" name="email" required><br>
    Message: <textarea name="message" required></textarea><br>
    <input type="submit" value="Send Message">
</form>

<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $name = $_POST['name'];
    $email = $_POST['email'];
    $message = $_POST['message'];
    
    $to = "admin@example.com";
    $subject = "Contact Form Submission from $name";
    $body = "Name: $name\nEmail: $email\nMessage:\n$message";
    $headers = "From: $email";

    if (mail($to, $subject, $body, $headers)) {
        echo "Your message has been sent!";
    } else {
        echo "Failed to send your message.";
    }
}
?>

<form method="post">
    Username: <input type="text" name="username" value="current_username" required><br>
    Email: <input type="email" name="email" value="current_email" required><br>
    New Password: <input type="password" name="new_password"><br>
    <input type="submit" value="Update Profile">
</form>

<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $username = $_POST['username'];
    $email = $_POST['email'];
    $new_password = $_POST['new_password'];

    $servername = "localhost";
    $db_username = "root";
    $db_password = "";
    $dbname = "users";

    $conn = new mysqli($servername, $db_username, $db_password, $dbname);

    if ($conn->connect_error) {
        die("Connection failed: " . $conn->connect_error);
    }

    $sql = "UPDATE users SET username='$username', email='$email', password='$new_password' WHERE username='$username'";
    if ($conn->query($sql) === TRUE) {
        echo "Profile updated successfully!";
    } else {
        echo "Error: " . $conn->error;
    }
    $conn->close();
}
?>

<form method="post">
    File: <input type="file" name="file_to_upload"><br>
    <input type="submit" value="Upload File">
</form>

<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $target_dir = "uploads/";
    $target_file = $target_dir . basename($_FILES["file_to_upload"]["name"]);
    if (move_uploaded_file($_FILES["file_to_upload"]["tmp_name"], $target_file)) {
        echo "The file ". htmlspecialchars(basename($_FILES["file_to_upload"]["name"])) . " has been uploaded.";
    } else {
        echo "Sorry, there was an error uploading your file.";
    }
}
?>

<form method="post">
    Vote for your favorite color:<br>
    <input type="radio" name="color" value="Red"> Red<br>
    <input type="radio" name="color" value="Blue"> Blue<br>
    <input type="radio" name="color" value="Green"> Green<br>
    <input type="submit" value="Vote">
</form>

<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $color = $_POST['color'];
    echo "Thank you for voting for $color!";
}
?>

<form method="post">
    Name: <input type="text" name="name" required><br>
    Email: <input type="email" name="email" required><br>
    Message: <textarea name="message" required></textarea><br>
    <input type="submit" value="Send Message">
</form>

<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $name = $_POST['name'];
    $email = $_POST['email'];
    $message = $_POST['message'];

    $to = "admin@example.com";
    $subject = "Contact Us Message from $name";
    $body = "Name: $name\nEmail: $email\nMessage:\n$message";
    $headers = "From: $email";

    if (mail($to, $subject, $body, $headers)) {
        echo "Your message has been sent!";
    } else {
        echo "Failed to send your message.";
    }
}
?>

<form method="post">
    Username: <input type="text" name="username" required><br>
    Password: <input type="password" name="password" required><br>
    <input type="submit" value="Login">
</form>

<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $username = $_POST['username'];
    $password = $_POST['password'];

    $servername = "localhost";
    $db_username = "root";
    $db_password = "";
    $dbname = "users";

    $conn = new mysqli($servername, $db_username, $db_password, $dbname);

    if ($conn->connect_error) {
        die("Connection failed: " . $conn->connect_error);
    }

    $sql = "SELECT * FROM users WHERE username='$username' AND password='$password'";
    $result = $conn->query($sql);

    if ($result->num_rows > 0) {
        echo "Welcome back, $username!";
    } else {
        echo "Invalid login credentials!";
    }
    $conn->close();
}
?>

<form method="post">
    Email: <input type="email" name="email" required><br>
    <input type="submit" value="Subscribe">
</form>

<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $email = $_POST['email'];
    echo "Thank you for subscribing, $email!";
    // Here, you would typically save the email to a database for further use
}
?>

<form method="post">
    Search for Product: <input type="text" name="search_query" required><br>
    <input type="submit" value="Search">
</form>

<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $search_query = $_POST['search_query'];
    // Sample product array for demonstration
    $products = ["Laptop", "Smartphone", "Tablet", "Smartwatch", "Headphones"];
    $results = array_filter($products, function($product) use ($search_query) {
        return strpos(strtolower($product), strtolower($search_query)) !== false;
    });

    if (count($results) > 0) {
        echo "Search Results: " . implode(", ", $results);
    } else {
        echo "No products found!";
    }
}
?>

<form method="post">
    Name: <input type="text" name="name" required><br>
    Feedback: <textarea name="feedback" required></textarea><br>
    <input type="submit" value="Submit Feedback">
</form>

<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $name = $_POST['name'];
    $feedback = $_POST['feedback'];
    echo "Thank you for your feedback, $name! You said: $feedback";
    // Feedback would typically be saved in a database or sent via email
}
?>

<form method="post">
    Your Message: <textarea name="message"></textarea><br>
    <input type="submit" value="Send Message">
</form>

<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $message = $_POST['message'];
    echo "You sent: $message";
    // Here, you would typically store the message in a database or display it in a chat interface
}
?>

<form method="post">
    Task Title: <input type="text" name="task_title" required><br>
    Task Description: <textarea name="task_description" required></textarea><br>
    <input type="submit" value="Add Task">
</form>

<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $task_title = $_POST['task_title'];
    $task_description = $_POST['task_description'];
    echo "Task Added: $task_title - $task_description";
    // You would typically save the task in a database and display it in a task list
}
?>

<form method="post" enctype="multipart/form-data">
    Select image to upload: <input type="file" name="image"><br>
    <input type="submit" value="Upload Image">
</form>

<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $target_dir = "uploads/";
    $target_file = $target_dir . basename($_FILES["image"]["name"]);
    if (move_uploaded_file($_FILES["image"]["tmp_name"], $target_file)) {
        echo "The image ". htmlspecialchars(basename($_FILES["image"]["name"])) . " has been uploaded.";
    } else {
        echo "Sorry, there was an error uploading your image.";
    }
}
?>

<form method="post">
    Name: <input type="text" name="name" required><br>
    Email: <input type="email" name="email" required><br>
    Event: <select name="event">
        <option value="Event1">Event 1</option>
        <option value="Event2">Event 2</option>
    </select><br>
    <input type="submit" value="Register">
</form>

<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $name = $_POST['name'];
    $email = $_POST['email'];
    $event = $_POST['event'];
    echo "Thank you, $name! You have successfully registered for $event.";
}
?>

<form method="post">
    Employee ID: <input type="text" name="employee_id" required><br>
    Date: <input type="date" name="date" required><br>
    Status: <select name="status">
        <option value="Present">Present</option>
        <option value="Absent">Absent</option>
    </select><br>
    <input type="submit" value="Submit Attendance">
</form>

<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $employee_id = $_POST['employee_id'];
    $date = $_POST['date'];
    $status = $_POST['status'];
    echo "Attendance recorded for employee $employee_id on $date as $status.";
}
?>

<form method="post">
    Item Name: <input type="text" name="item_name" required><br>
    Quantity: <input type="number" name="quantity" required><br>
    Price: <input type="number" name="price" required><br>
    <input type="submit" value="Add Item">
</form>

<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $item_name = $_POST['item_name'];
    $quantity = $_POST['quantity'];
    $price = $_POST['price'];
    echo "Item Added: $item_name, Quantity: $quantity, Price: $price";
    // Normally, you'd save this data to a database for inventory management
}
?>

<form method="post">
    Name: <input type="text" name="name" required><br>
    Email: <input type="email" name="email" required><br>
    Feedback: <textarea name="feedback" required></textarea><br>
    <input type="submit" value="Submit Feedback">
</form>

<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $name = $_POST['name'];
    $email = $_POST['email'];
    $feedback = $_POST['feedback'];
    echo "Thank you, $name! Your feedback has been submitted.";
    // You would typically save this feedback to a database or send it for review
}
?>

<form method="post">
    Employee ID: <input type="text" name="employee_id" required><br>
    Clock In Time: <input type="time" name="clock_in" required><br>
    Clock Out Time: <input type="time" name="clock_out" required><br>
    <input type="submit" value="Submit Time Entry">
</form>

<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $employee_id = $_POST['employee_id'];
    $clock_in = $_POST['clock_in'];
    $clock_out = $_POST['clock_out'];
    $total_time = strtotime($clock_out) - strtotime($clock_in);
    echo "Employee $employee_id worked for " . gmdate("H:i:s", $total_time);
}
?>

<form method="post">
    Task Name: <input type="text" name="task_name" required><br>
    Task Deadline: <input type="date" name="task_deadline" required><br>
    <input type="submit" value="Add Task">
</form>

<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $task_name = $_POST['task_name'];
    $task_deadline = $_POST['task_deadline'];
    echo "Task '$task_name' added with deadline on $task_deadline.";
    // Save task data to a database for tracking
}
?>

<form method="post">
    Question: <input type="text" name="question" required><br>
    Option 1: <input type="text" name="option1" required><br>
    Option 2: <input type="text" name="option2" required><br>
    <input type="submit" value="Create Poll">
</form>

<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $question = $_POST['question'];
    $option1 = $_POST['option1'];
    $option2 = $_POST['option2'];
    echo "Poll created: $question
Option 1: $option1
Option 2: $option2"; // Poll data would be stored for user interaction } ?>

<form method="post">
    Title: <input type="text" name="title" required><br>
    Note: <textarea name="note" required></textarea><br>
    <input type="submit" value="Save Note">
</form>

<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $title = $_POST['title'];
    $note = $_POST['note'];
    echo "Note '$title' saved with content: $note";
    // Normally, you'd save the note to a database for future retrieval
}
?>

<form method="post">
    Weight (kg): <input type="number" name="weight" required><br>
    Height (m): <input type="number" step="0.01" name="height" required><br>
    <input type="submit" value="Calculate BMI">
</form>

<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $weight = $_POST['weight'];
    $height = $_POST['height'];
    $bmi = $weight / ($height * $height);
    echo "Your BMI is: " . round($bmi, 2);
}
?>

<form method="post">
    Amount: <input type="number" name="amount" required><br>
    From Currency: <input type="text" name="from_currency" required><br>
    To Currency: <input type="text" name="to_currency" required><br>
    <input type="submit" value="Convert">
</form>

<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $amount = $_POST['amount'];
    $from_currency = $_POST['from_currency'];
    $to_currency = $_POST['to_currency'];
    // Conversion logic here, like calling an API to get the exchange rate
    echo "Converted $amount $from_currency to $to_currency.";
}
?>

<?php
$quotes = array(
    "The only way to do great work is to love what you do.",
    "Life is what happens when you're busy making other plans.",
    "Get busy living or get busy dying."
);
$random_quote = $quotes[array_rand($quotes)];
echo "Random Quote: $random_quote";
?>

<form method="post">
    Birthdate: <input type="date" name="birthdate" required><br>
    <input type="submit" value="Calculate Age">
</form>

<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $birthdate = $_POST['birthdate'];
    $age = date_diff(date_create($birthdate), date_create('today'))->y;
    echo "You are $age years old.";
}
?>

<form method="post">
    Number 1: <input type="number" name="num1" required><br>
    Number 2: <input type="number" name="num2" required><br>
    Operation: 
    <select name="operation">
        <option value="add">Add</option>
        <option value="subtract">Subtract</option>
        <option value="multiply">Multiply</option>
        <option value="divide">Divide</option>
    </select><br>
    <input type="submit" value="Calculate">
</form>

<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $num1 = $_POST['num1'];
    $num2 = $_POST['num2'];
    $operation = $_POST['operation'];
    if ($operation == "add") {
        $result = $num1 + $num2;
    } elseif ($operation == "subtract") {
        $result = $num1 - $num2;
    } elseif ($operation == "multiply") {
        $result = $num1 * $num2;
    } elseif ($operation == "divide") {
        $result = $num1 / $num2;
    }
    echo "Result: $result";
    // Save calculation history in a database or session if needed
}
?>

<form method="post">
    Name: <input type="text" name="contact_name" required><br>
    Phone: <input type="text" name="phone_number" required><br>
    Email: <input type="email" name="email" required><br>
    <input type="submit" value="Add Contact">
</form>

<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $contact_name = $_POST['contact_name'];
    $phone_number = $_POST['phone_number'];
    $email = $_POST['email'];
    echo "Contact Added: $contact_name, Phone: $phone_number, Email: $email";
    // Normally, you'd store this contact data in a database
}
?>

<form method="post">
    City: <input type="text" name="city" required><br>
    <input type="submit" value="Get Weather">
</form>

<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $city = $_POST['city'];
    // API call to get weather data (use an actual API for this)
    echo "Weather forecast for $city: 25°C, Clear sky.";
}
?>

<form method="post">
    Question: <input type="text" name="question" required><br>
    Answer: <input type="text" name="answer" required><br>
    <input type="submit" value="Add Flashcard">
</form>

<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $question = $_POST['question'];
    $answer = $_POST['answer'];
    echo "Flashcard added: Question: $question, Answer: $answer";
    // Save flashcard to a database
}
?>

<form method="post">
    Item: <input type="text" name="item" required><br>
    Amount: <input type="number" name="amount" required><br>
    Date: <input type="date" name="date" required><br>
    <input type="submit" value="Add Expense">
</form>

<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $item = $_POST['item'];
    $amount = $_POST['amount'];
    $date = $_POST['date'];
    echo "Expense added: $item for $amount on $date";
    // Save expense data to a database for tracking
}
?>

<form method="post">
    Time in seconds: <input type="number" name="time" required><br>
    <input type="submit" value="Start Timer">
</form>

<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $time = $_POST['time'];
    echo "Starting countdown for $time seconds.";
    // JavaScript or a backend cron job can handle the countdown process
}
?>

<form method="post">
    Candidate Name: <input type="text" name="candidate" required><br>
    Vote: <input type="number" name="vote" required><br>
    <input type="submit" value="Vote">
</form>

<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $candidate = $_POST['candidate'];
    $vote = $_POST['vote'];
    echo "You voted for $candidate, with $vote votes.";
    // Store the vote in a database for election tracking
}
?>

<form method="post">
    Ingredient: <input type="text" name="ingredient" required><br>
    <input type="submit" value="Find Recipes">
</form>

<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $ingredient = $_POST['ingredient'];
    // API or database query to find recipes using the ingredient
    echo "Recipes with $ingredient: Pasta, Salad, Smoothie.";
}
?>

<form method="post">
    Title: <input type="text" name="title" required><br>
    Content: <textarea name="content" required></textarea><br>
    <input type="submit" value="Post Blog">
</form>

<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $title = $_POST['title'];
    $content = $_POST['content'];
    echo "Blog post added: Title: $title, Content: $content";
    // Store blog post in a database
}
?>

<form method="post">
    Monthly Income: <input type="number" name="income" required><br>
    Expenses: <input type="number" name="expenses" required><br>
    Savings: <input type="number" name="savings" required><br>
    <input type="submit" value="Calculate Balance">
</form>

<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $income = $_POST['income'];
    $expenses = $_POST['expenses'];
    $savings = $_POST['savings'];
    $balance = $income - $expenses - $savings;
    echo "Remaining balance after expenses and savings: $balance";
}
?>

<form method="post">
    Task Name: <input type="text" name="task_name" required><br>
    Due Date: <input type="date" name="due_date" required><br>
    Priority: 
    <select name="priority">
        <option value="high">High</option>
        <option value="medium">Medium</option>
        <option value="low">Low</option>
    </select><br>
    <input type="submit" value="Add Task">
</form>

<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $task_name = $_POST['task_name'];
    $due_date = $_POST['due_date'];
    $priority = $_POST['priority'];
    echo "Task added: $task_name, Due: $due_date, Priority: $priority";
    // Save the task to a database or file
}
?>

<form method="post">
    Name: <input type="text" name="name" required><br>
    Email: <input type="email" name="email" required><br>
    Phone: <input type="text" name="phone" required><br>
    <input type="submit" value="Add Contact">
</form>

<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $name = $_POST['name'];
    $email = $_POST['email'];
    $phone = $_POST['phone'];
    echo "Contact added: Name: $name, Email: $email, Phone: $phone";
    // Store the contact in a database or file
}
?>

<form method="post" enctype="multipart/form-data">
    Choose image: <input type="file" name="image" required><br>
    <input type="submit" value="Upload Image">
</form>

<?php
if ($_SERVER["REQUEST_METHOD"] == "POST" && isset($_FILES['image'])) {
    // Call AI API (e.g., Google Vision, Clarifai)
    $image = $_FILES['image']['tmp_name'];
    $api_url = "https://api.ai.com/recognize";
    $response = file_get_contents($api_url . "?image=" . urlencode($image));
    echo "AI recognition result: " . $response;
}
?>

<form method="post">
    User Question: <input type="text" name="question" required><br>
    <input type="submit" value="Ask">
</form>

<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $question = $_POST['question'];
    // Call AI service (e.g., OpenAI API)
    $response = file_get_contents("https://api.openai.com/v1/chat/completions?question=" . urlencode($question));
    echo "AI Response: " . $response;
}
?>

<form method="post">
    Enter text: <input type="text" name="text" required><br>
    <input type="submit" value="Analyze Sentiment">
</form>

<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $text = $_POST['text'];
    // Call AI sentiment analysis API (e.g., IBM Watson or Sentiment API)
    $api_url = "https://api.sentiment.com/analyze";
    $response = file_get_contents($api_url . "?text=" . urlencode($text));
    echo "Sentiment: " . $response;
}
?>

<form method="post" enctype="multipart/form-data">
    Upload black & white image: <input type="file" name="image" required><br>
    <input type="submit" value="Colorize Image">
</form>

<?php
if ($_SERVER["REQUEST_METHOD"] == "POST" && isset($_FILES['image'])) {
    // Call AI colorization API
    $image = $_FILES['image']['tmp_name'];
    $api_url = "https://api.ai.com/colorize";
    $response = file_get_contents($api_url . "?image=" . urlencode($image));
    echo "Colorized image: " . $response;
}
?>

<form method="post">
    Ingredients: <input type="text" name="ingredients" required><br>
    <input type="submit" value="Generate Recipe">
</form>

<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $ingredients = $_POST['ingredients'];
    // Call AI recipe generation API
    $api_url = "https://api.recipe.com/generate";
    $response = file_get_contents($api_url . "?ingredients=" . urlencode($ingredients));
    echo "Generated Recipe: " . $response;
}
?>

<form method="post">
    Article URL: <input type="text" name="url" required><br>
    <input type="submit" value="Summarize Article">
</form>

<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $url = $_POST['url'];
    // Call AI summarizer API
    $api_url = "https://api.summarizer.com";
    $response = file_get_contents($api_url . "?url=" . urlencode($url));
    echo "Article Summary: " . $response;
}
?>

<form method="post">
    Your Request: <input type="text" name="request" required><br>
    <input type="submit" value="Get Response">
</form>

<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $request = $_POST['request'];
    // Call AI assistant API
    $api_url = "https://api.assistant.com/respond";
    $response = file_get_contents($api_url . "?query=" . urlencode($request));
    echo "Assistant Response: " . $response;
}
?>

<form method="post">
    Voice Command: <input type="text" name="command" required><br>
    <input type="submit" value="Execute Command">
</form>

<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $command = $_POST['command'];
    // Call AI voice recognition API
    $api_url = "https://api.voice.com/command";
    $response = file_get_contents($api_url . "?command=" . urlencode($command));
    echo "Voice Command Response: " . $response;
}
?>

<form method="post">
    Enter Text: <input type="text" name="text" required><br>
    Select Language: <select name="language">
        <option value="en">English</option>
        <option value="es">Spanish</option>
        <option value="fr">French</option>
    </select><br>
    <input type="submit" value="Translate">
</form>

<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $text = $_POST['text'];
    $language = $_POST['language'];
    // Call AI translation API
    $api_url = "https://api.translate.com/translate";
    $response = file_get_contents($api_url . "?text=" . urlencode($text) . "&language=" . $language);
    echo "Translated Text: " . $response;
}
?>

<form method="post">
    Enter your preferences: <input type="text" name="preferences" required><br>
    <input type="submit" value="Find Products">
</form>

<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $preferences = $_POST['preferences'];
    // Call AI product recommendation API
    $api_url = "https://api.shop.com/recommend";
    $response = file_get_contents($api_url . "?preferences=" . urlencode($preferences));
    echo "Recommended Products: " . $response;
}
?>

<form method="post">
    Enter text to summarize: <input type="text" name="text" required><br>
    <input type="submit" value="Summarize">
</form>

<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $text = $_POST['text'];
    // Call AI summarizer API (e.g., GPT-3)
    $api_url = "https://api.summarizer.com";
    $response = file_get_contents($api_url . "?text=" . urlencode($text));
    echo "Summary: " . $response;
}
?>

<form method="post">
    Record Speech: <input type="file" name="audio" accept="audio/*" required><br>
    <input type="submit" value="Convert to Text">
</form>

<?php
if ($_SERVER["REQUEST_METHOD"] == "POST" && isset($_FILES['audio'])) {
    $audio = $_FILES['audio']['tmp_name'];
    // Call AI Speech-to-Text API (e.g., Google Speech-to-Text)
    $api_url = "https://api.speech.com/convert";
    $response = file_get_contents($api_url . "?audio=" . urlencode($audio));
    echo "Transcribed Text: " . $response;
}
?>

<form method="post" enctype="multipart/form-data">
    Upload Image for Object Detection: <input type="file" name="image" required><br>
    <input type="submit" value="Detect Objects">
</form>

<?php
if ($_SERVER["REQUEST_METHOD"] == "POST" && isset($_FILES['image'])) {
    $image = $_FILES['image']['tmp_name'];
    // Call AI Object Detection API (e.g., TensorFlow or OpenCV)
    $api_url = "https://api.objectdetection.com";
    $response = file_get_contents($api_url . "?image=" . urlencode($image));
    echo "Detected Objects: " . $response;
}
?>

<form method="post">
    Upload Resume: <input type="file" name="resume" required><br>
    <input type="submit" value="Analyze Resume">
</form>

<?php
if ($_SERVER["REQUEST_METHOD"] == "POST" && isset($_FILES['resume'])) {
    $resume = $_FILES['resume']['tmp_name'];
    // Call AI Resume Screening API (e.g., Skill matching AI)
    $api_url = "https://api.resumescreening.com";
    $response = file_get_contents($api_url . "?resume=" . urlencode($resume));
    echo "Resume Analysis: " . $response;
}
?>

<form method="post" enctype="multipart/form-data">
    Upload Image for Face Recognition: <input type="file" name="image" required><br>
    <input type="submit" value="Recognize Face">
</form>

<?php
if ($_SERVER["REQUEST_METHOD"] == "POST" && isset($_FILES['image'])) {
    $image = $_FILES['image']['tmp_name'];
    // Call AI Face Recognition API (e.g., Microsoft Azure Face API)
    $api_url = "https://api.facerecognition.com";
    $response = file_get_contents($api_url . "?image=" . urlencode($image));
    echo "Face Recognition Result: " . $response;
}
?>

<form method="post" enctype="multipart/form-data">
    Upload Audio for Emotion Detection: <input type="file" name="audio" required><br>
    <input type="submit" value="Analyze Emotion">
</form>

<?php
if ($_SERVER["REQUEST_METHOD"] == "POST" && isset($_FILES['audio'])) {
    $audio = $_FILES['audio']['tmp_name'];
    // Call AI Emotion Detection API (e.g., Affectiva)
    $api_url = "https://api.emotiondetection.com";
    $response = file_get_contents($api_url . "?audio=" . urlencode($audio));
    echo "Detected Emotion: " . $response;
}
?>

<form method="post" enctype="multipart/form-data">
    Upload Handwritten Text: <input type="file" name="image" required><br>
    <input type="submit" value="Recognize Handwriting">
</form>

<?php
if ($_SERVER["REQUEST_METHOD"] == "POST" && isset($_FILES['image'])) {
    $image = $_FILES['image']['tmp_name'];
    // Call AI Handwriting Recognition API (e.g., Google Cloud Vision)
    $api_url = "https://api.handwritingrecognition.com";
    $response = file_get_contents($api_url . "?image=" . urlencode($image));
    echo "Recognized Text: " . $response;
}
?>

<form method="post">
    Enter your favorite genre: <input type="text" name="genre" required><br>
    <input type="submit" value="Get Recommendations">
</form>

<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $genre = $_POST['genre'];
    // Call AI Movie Recommendation API (e.g., MovieLens or IMDB)
    $api_url = "https://api.movierecommender.com";
    $response = file_get_contents($api_url . "?genre=" . urlencode($genre));
    echo "Recommended Movies: " . $response;
}
?>

<form method="post">
    Enter text for sentiment analysis: <input type="text" name="text" required><br>
    <input type="submit" value="Analyze Sentiment">
</form>

<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $text = $_POST['text'];
    // Call AI Sentiment Analysis API (e.g., IBM Watson or TextBlob)
    $api_url = "https://api.sentimentanalysis.com";
    $response = file_get_contents($api_url . "?text=" . urlencode($text));
    echo "Sentiment: " . $response;
}
?>

<form method="post" enctype="multipart/form-data">
    Upload Voice Command: <input type="file" name="audio" required><br>
    <input type="submit" value="Get Response">
</form>

<?php
if ($_SERVER["REQUEST_METHOD"] == "POST" && isset($_FILES['audio'])) {
    $audio = $_FILES['audio']['tmp_name'];
    // Call AI Voice Assistant API (e.g., Google Assistant API)
    $api_url = "https://api.voiceassistant.com";
    $response = file_get_contents($api_url . "?audio=" . urlencode($audio));
    echo "Assistant Response: " . $response;
}
?>

<form method="post">
    Enter text for translation: <input type="text" name="text" required><br>
    Select Language: <select name="language">
        <option value="fr">French</option>
        <option value="es">Spanish</option>
        <option value="de">German</option>
    </select><br>
    <input type="submit" value="Translate">
</form>

<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $text = $_POST['text'];
    $language = $_POST['language'];
    // Call AI Language Translation API (e.g., Google Translate)
    $api_url = "https://api.translator.com";
    $response = file_get_contents($api_url . "?text=" . urlencode($text) . "&lang=" . $language);
    echo "Translated Text: " . $response;
}
?>

<form method="post">
    Enter your news interest: <input type="text" name="interest" required><br>
    <input type="submit" value="Get News">
</form>

<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $interest = $_POST['interest'];
    // Call AI News Aggregator API (e.g., Google News API)
    $api_url = "https://api.newsaggregator.com";
    $response = file_get_contents($api_url . "?interest=" . urlencode($interest));
    echo "News: " . $response;
}
?>

<form method="post">
    Enter ingredients you have: <input type="text" name="ingredients" required><br>
    <input type="submit" value="Generate Recipe">
</form>

<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $ingredients = $_POST['ingredients'];
    // Call AI Recipe Generator API (e.g., Spoonacular API)
    $api_url = "https://api.recipegenerator.com";
    $response = file_get_contents($api_url . "?ingredients=" . urlencode($ingredients));
    echo "Suggested Recipe: " . $response;
}
?>

<form method="post">
    Enter your fitness goal: <input type="text" name="goal" required><br>
    <input type="submit" value="Track Progress">
</form>

<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $goal = $_POST['goal'];
    // Call AI Fitness Tracker API (e.g., MyFitnessPal)
    $api_url = "https://api.fitnesstracker.com";
    $response = file_get_contents($api_url . "?goal=" . urlencode($goal));
    echo "Progress: " . $response;
}
?>

<form method="post">
    Ask a question: <input type="text" name="question" required><br>
    <input type="submit" value="Ask Chatbot">
</form>

<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $question = $_POST['question'];
    // Call AI Chatbot API (e.g., OpenAI GPT-3)
    $api_url = "https://api.chatbot.com";
    $response = file_get_contents($api_url . "?question=" . urlencode($question));
    echo "Chatbot Response: " . $response;
}
?>

<form method="post">
    Enter your job experience: <textarea name="experience" required></textarea><br>
    Enter your skills: <textarea name="skills" required></textarea><br>
    <input type="submit" value="Generate Resume">
</form>

<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $experience = $_POST['experience'];
    $skills = $_POST['skills'];
    // Call AI Resume Builder API (e.g., Resume.io)
    $api_url = "https://api.resumebuilder.com";
    $response = file_get_contents($api_url . "?experience=" . urlencode($experience) . "&skills=" . urlencode($skills));
    echo "Generated Resume: " . $response;
}
?>

<form method="post" enctype="multipart/form-data">
    Upload Image: <input type="file" name="image" required><br>
    <input type="submit" value="Generate Caption">
</form>

<?php
if ($_SERVER["REQUEST_METHOD"] == "POST" && isset($_FILES['image'])) {
    $image = $_FILES['image']['tmp_name'];
    // Call AI Image Captioning API (e.g., Microsoft Azure Computer Vision)
    $api_url = "https://api.imagecaptioning.com";
    $response = file_get_contents($api_url . "?image=" . urlencode($image));
    echo "Generated Caption: " . $response;
}
?>

<form method="post">
    Enter a sentence in English: <input type="text" name="sentence" required><br>
    <input type="submit" value="Translate to Spanish">
</form>

<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $sentence = $_POST['sentence'];
    // Call AI Language Learning API (e.g., Google Translate)
    $api_url = "https://api.languagelearning.com";
    $response = file_get_contents($api_url . "?sentence=" . urlencode($sentence) . "&target_lang=es");
    echo "Translated Sentence: " . $response;
}
?>

<form method="post">
    Enter transaction details: <textarea name="transaction" required></textarea><br>
    <input type="submit" value="Check for Fraud">
</form>

<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $transaction = $_POST['transaction'];
    // Call AI Fraud Detection API (e.g., PayPal or Stripe)
    $api_url = "https://api.frauddetection.com";
    $response = file_get_contents($api_url . "?transaction=" . urlencode($transaction));
    echo "Fraud Check Result: " . $response;
}
?>

<form method="post">
    Enter email content: <textarea name="email_content" required></textarea><br>
    <input type="submit" value="Classify Email">
</form>

<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $email_content = $_POST['email_content'];
    // Call AI Email Classification API (e.g., Google Cloud Natural Language)
    $api_url = "https://api.emailclassification.com";
    $response = file_get_contents($api_url . "?content=" . urlencode($email_content));
    echo "Email Classification: " . $response;
}
?>

<form method="post">
    Enter your interest (e.g., music, art, sports): <input type="text" name="interest" required><br>
    <input type="submit" value="Get Event Recommendations">
</form>

<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $interest = $_POST['interest'];
    // Call AI Event Recommendation API (e.g., Eventbrite)
    $api_url = "https://api.eventrecommendation.com";
    $response = file_get_contents($api_url . "?interest=" . urlencode($interest));
    echo "Recommended Events: " . $response;
}
?>

<form method="post">
    Enter your shopping preference: <input type="text" name="preference" required><br>
    <input type="submit" value="Get Shopping Recommendations">
</form>

<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $preference = $_POST['preference'];
    // Call AI Virtual Shopping Assistant API (e.g., Shopify AI)
    $api_url = "https://api.virtualshopper.com";
    $response = file_get_contents($api_url . "?preference=" . urlencode($preference));
    echo "Shopping Recommendations: " . $response;
}
?>

<form method="post">
    
    Enter fitness goal: <input type="text" name="goal" required><br>
    
    <input type="submit" value="Get Nutrition Plan">
</form>

<?php
// Check if the form is submitted
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    // Get the user's fitness goal from the form input
    $goal = $_POST['goal'];
    
    // API URL for AI-powered nutrition plan generator
    $api_url = "https://api.fitnessnutrition.com";
    
    // Send the user's goal to the API and get the nutrition plan response
    $response = file_get_contents($api_url . "?goal=" . urlencode($goal));
    
    // Display the generated nutrition plan
    echo "Generated Nutrition Plan: " . $response;
}
?>

<form method="post">
    
    Enter your favorite genre: <input type="text" name="genre" required><br>
    
    <input type="submit" value="Get Music Recommendations">
</form>

<?php
// Check if the form is submitted
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    // Get the music genre preference from the form input
    $genre = $_POST['genre'];
    
    // API URL for AI-powered music recommendation system
    $api_url = "https://api.musicrecommendation.com";
    
    // Send the genre to the API and get the recommended music list
    $response = file_get_contents($api_url . "?genre=" . urlencode($genre));
    
    // Display the recommended music list
    echo "Recommended Music: " . $response;
}
?>

<form method="post">
    
    Enter your travel destination: <input type="text" name="destination" required><br>
    
    <input type="submit" value="Get Travel Recommendations">
</form>

<?php
// Check if the form is submitted
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    // Get the travel destination from the form input
    $destination = $_POST['destination'];
    
    // API URL for AI-powered virtual travel assistant
    $api_url = "https://api.travelassistant.com";
    
    // Send the destination to the API and get the recommended travel tips
    $response = file_get_contents($api_url . "?destination=" . urlencode($destination));
    
    // Display the travel recommendations
    echo "Travel Recommendations: " . $response;
}
?>

<form method="post">
    
    Enter your code for review: <textarea name="code" required></textarea><br>
    
    <input type="submit" value="Review Code">
</form>

<?php
// Check if the form is submitted
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    // Get the user's code from the form input
    $code = $_POST['code'];
    
    // API URL for AI-powered code review assistant
    $api_url = "https://api.codereview.com";
    
    // Send the code to the API and get the review
    $response = file_get_contents($api_url . "?code=" . urlencode($code));
    
    // Display the code review
    echo "Code Review Feedback: " . $response;
}
?>

<form method="post">
    
    Enter your monthly income: <input type="number" name="income" required><br>
    Enter your monthly expenses: <input type="number" name="expenses" required><br>
    
    <input type="submit" value="Get Financial Advice">
</form>

<?php
// Check if the form is submitted
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    // Get the user's financial data from the form input
    $income = $_POST['income'];
    $expenses = $_POST['expenses'];
    
    // API URL for AI-powered finance assistant
    $api_url = "https://api.financemanager.com";
    
    // Send the financial details to the API and get the advice
    $response = file_get_contents($api_url . "?income=" . urlencode($income) . "&expenses=" . urlencode($expenses));
    
    // Display the financial advice
    echo "Financial Advice: " . $response;
}
?>

<form method="post">
    
    Enter your favorite movie genre: <input type="text" name="genre" required><br>
    
    <input type="submit" value="Get Movie Recommendations">
</form>

<?php
// Check if the form is submitted
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    // Get the movie genre from the form input
    $genre = $_POST['genre'];
    
    // API URL for AI-powered movie recommendation system
    $api_url = "https://api.movierecommendation.com";
    
    // Send the genre to the API and get the recommended movies
    $response = file_get_contents($api_url . "?genre=" . urlencode($genre));
    
    // Display the movie recommendations
    echo "Recommended Movies: " . $response;
}
?>

<?php
// Accept meeting notes as input
$notes = $_POST['notes'] ?? '';

// Prepare prompt for summarization
$data = [
  'prompt' => "Summarize the following meeting notes into key points:\n$notes",
  'max_tokens' => 150
];

// Setup API context
$options = [
  'http' => [
    'header' => "Content-Type: application/json\r\n",
    'method' => 'POST',
    'content' => json_encode($data)
  ]
];

$context = stream_context_create($options);

// Send API request
$response = file_get_contents('https://api.openai.com/v1/completions', false, $context);

// Output summarized notes
echo $response;
?>
      

<?php
// Get email body
$email = $_POST['email'] ?? '';

// Define prompt for classification
$data = [
  'prompt' => "Classify this email as 'Urgent' or 'Not Urgent':\n$email",
  'temperature' => 0.3,
  'max_tokens' => 10
];

// API context setup
$options = [
  'http' => [
    'header' => "Content-Type: application/json\r\n",
    'method' => 'POST',
    'content' => json_encode($data)
  ]
];

$context = stream_context_create($options);

// Get classification from AI
$response = file_get_contents('https://api.openai.com/v1/completions', false, $context);

// Show classification
echo $response;
?>
      

<?php
// Get job title and field
$title = $_POST['title'] ?? 'Frontend Developer';

// Create prompt for job description
$data = [
  'prompt' => "Write a professional job description for a $title role",
  'max_tokens' => 200
];

// Define HTTP request
$options = [
  'http' => [
    'header' => "Content-Type: application/json\r\n",
    'method' => 'POST',
    'content' => json_encode($data)
  ]
];

$context = stream_context_create($options);

// Fetch response from AI
$response = file_get_contents('https://api.openai.com/v1/completions', false, $context);

// Output job description
echo $response;
?>
      

<?php
// Receive support ticket message
$ticket = $_POST['ticket'] ?? '';

// Generate helpful response
$data = [
  'prompt' => "Reply to this customer support ticket professionally:\n$ticket",
  'max_tokens' => 150
];

// Configure HTTP call
$options = [
  'http' => [
    'header' => "Content-Type: application/json\r\n",
    'method' => 'POST',
    'content' => json_encode($data)
  ]
];

$context = stream_context_create($options);

// Get AI-generated reply
$response = file_get_contents('https://api.openai.com/v1/completions', false, $context);

// Print response
echo $response;
?>
      

<?php
// Accept product or topic
$topic = $_POST['topic'] ?? 'website hosting';

// Generate FAQs
$data = [
  'prompt' => "Generate 5 common FAQs with answers about $topic.",
  'temperature' => 0.7,
  'max_tokens' => 250
];

// Define HTTP options
$options = [
  'http' => [
    'header' => "Content-Type: application/json\r\n",
    'method' => 'POST',
    'content' => json_encode($data)
  ]
];

$context = stream_context_create($options);

// AI output
$response = file_get_contents('https://api.openai.com/v1/completions', false, $context);

// Display FAQs
echo $response;
?>
      

<?php
// Get text and target language
$text = $_POST['text'] ?? '';
$lang = $_POST['lang'] ?? 'French';

// Create translation prompt
$data = [
  'prompt' => "Translate this to $lang:\n$text",
  'temperature' => 0.4,
  'max_tokens' => 100
];

// Set HTTP config
$options = [
  'http' => [
    'header' => "Content-Type: application/json\r\n",
    'method' => 'POST',
    'content' => json_encode($data)
  ]
];

$context = stream_context_create($options);

// Execute API request
$response = file_get_contents('https://api.openai.com/v1/completions', false, $context);

// Output translated text
echo $response;
?>
      

<?php
// User pastes legal text
$legal = $_POST['legal'] ?? '';

// Prompt to simplify it
$data = [
  'prompt' => "Simplify this legal text for a layperson:\n$legal",
  'temperature' => 0.6,
  'max_tokens' => 200
];

// Setup HTTP options
$options = [
  'http' => [
    'header' => "Content-Type: application/json\r\n",
    'method' => 'POST',
    'content' => json_encode($data)
  ]
];

$context = stream_context_create($options);

// Request AI summary
$response = file_get_contents('https://api.openai.com/v1/completions', false, $context);

// Display simplified text
echo $response;
?>
      

<?php
// Get user fitness goal and level
$goal = $_POST['goal'] ?? 'build muscle';
$level = $_POST['level'] ?? 'beginner';

// Create prompt for AI
$data = [
  'prompt' => "Create a weekly workout plan for a $level looking to $goal.",
  'temperature' => 0.7,
  'max_tokens' => 200
];

// Define API request settings
$options = [
  'http' => [
    'header' => "Content-Type: application/json\r\n",
    'method' => 'POST',
    'content' => json_encode($data)
  ]
];

$context = stream_context_create($options);

// Request AI-generated workout plan
$response = file_get_contents('https://api.openai.com/v1/completions', false, $context);

// Output the plan
echo $response;
?>
      

<?php
// Receive contract clause from user
$clause = $_POST['clause'] ?? '';

// Generate simplified version
$data = [
  'prompt' => "Rewrite this contract clause in plain English:\n$clause",
  'temperature' => 0.6,
  'max_tokens' => 150
];

// API call configuration
$options = [
  'http' => [
    'header' => "Content-Type: application/json\r\n",
    'method' => 'POST',
    'content' => json_encode($data)
  ]
];

$context = stream_context_create($options);

// Fetch rewritten clause
$response = file_get_contents('https://api.openai.com/v1/completions', false, $context);

// Output plain-language clause
echo $response;
?>
      

<?php
// Receive property features
$features = $_POST['features'] ?? '3-bedroom, 2-bath, ocean view condo';

// Ask AI to write listing
$data = [
  'prompt' => "Write a compelling real estate listing for: $features",
  'temperature' => 0.75,
  'max_tokens' => 180
];

// Set HTTP context
$options = [
  'http' => [
    'header' => "Content-Type: application/json\r\n",
    'method' => 'POST',
    'content' => json_encode($data)
  ]
];

$context = stream_context_create($options);

// Generate listing
$response = file_get_contents('https://api.openai.com/v1/completions', false, $context);

// Output the AI-written ad
echo $response;
?>
      

<?php
// Receive user message
$user_msg = $_POST['message'] ?? 'I feel overwhelmed and anxious.';

// Ask AI to reply compassionately
$data = [
  'prompt' => "You are a supportive mental health chatbot. Respond to: '$user_msg'",
  'temperature' => 0.8,
  'max_tokens' => 150
];

// Define HTTP context
$options = [
  'http' => [
    'header' => "Content-Type: application/json\r\n",
    'method' => 'POST',
    'content' => json_encode($data)
  ]
];

$context = stream_context_create($options);

// Request response
$response = file_get_contents('https://api.openai.com/v1/completions', false, $context);

// Show reply
echo $response;
?>
      

<?php
// Get recipient interests
$interests = $_POST['interests'] ?? 'music, travel, and coffee';

// Prompt for personalized gift ideas
$data = [
  'prompt' => "Suggest 5 thoughtful gift ideas for someone who likes $interests.",
  'temperature' => 0.9,
  'max_tokens' => 150
];

// Prepare HTTP request
$options = [
  'http' => [
    'header' => "Content-Type: application/json\r\n",
    'method' => 'POST',
    'content' => json_encode($data)
  ]
];

$context = stream_context_create($options);

// Get AI suggestions
$response = file_get_contents('https://api.openai.com/v1/completions', false, $context);

// Output gift ideas
echo $response;
?>
      

<?php
// Capture the user's interview question
$question = $_POST['question'] ?? '';

// Prepare data for AI API
$data = [
  'prompt' => "Give a coaching answer for: $question",
  'temperature' => 0.7,
  'max_tokens' => 150
];

// Convert the array to JSON
$options = [
  'http' => [
    'header' => "Content-Type: application/json\r\n",
    'method' => 'POST',
    'content' => json_encode($data)
  ]
];

$context = stream_context_create($options);

// Send request to AI model
$response = file_get_contents('https://api.openai.com/v1/completions', false, $context);

// Show the result
echo $response;
?>
      

<?php
// Get the user's resume text
$resume = $_POST['resume'] ?? '';

// Format prompt
$data = [
  'prompt' => "Improve this resume for a professional tone:\n$resume",
  'max_tokens' => 200
];

// Setup API options
$options = [
  'http' => [
    'header' => "Content-Type: application/json\r\n",
    'method' => 'POST',
    'content' => json_encode($data)
  ]
];

$context = stream_context_create($options);

// Fetch enhanced version
$response = file_get_contents('https://api.openai.com/v1/completions', false, $context);

// Output
echo $response;
?>
      

<?php
// Receive industry name
$industry = $_POST['industry'] ?? 'Technology';

// Compose the prompt
$data = [
  'prompt' => "Suggest creative business logo names for a $industry startup",
  'temperature' => 0.8,
  'max_tokens' => 100
];

// Define request
$options = [
  'http' => [
    'header' => "Content-Type: application/json\r\n",
    'method' => 'POST',
    'content' => json_encode($data)
  ]
];

$context = stream_context_create($options);

// API response
$response = file_get_contents('https://api.openai.com/v1/completions', false, $context);

// Print names
echo $response;
?>
      

<?php
// User uploads image description
$desc = $_POST['desc'] ?? 'A picture of a sunset';

// Prompt for caption
$data = [
  'prompt' => "Create a catchy social media caption for: $desc",
  'temperature' => 0.9,
  'max_tokens' => 60
];

// API POST setup
$options = [
  'http' => [
    'header' => "Content-Type: application/json\r\n",
    'method' => 'POST',
    'content' => json_encode($data)
  ]
];

$context = stream_context_create($options);

// Send and display result
$response = file_get_contents('https://api.openai.com/v1/completions', false, $context);
echo $response;
?>
      

<?php
// Get diary entry
$diary = $_POST['diary'] ?? '';

// AI prompt
$data = [
  'prompt' => "Summarize this diary entry in one sentence: $diary",
  'temperature' => 0.5,
  'max_tokens' => 50
];

// Request configuration
$options = [
  'http' => [
    'header' => "Content-Type: application/json\r\n",
    'method' => 'POST',
    'content' => json_encode($data)
  ]
];

$context = stream_context_create($options);

// Show result
$response = file_get_contents('https://api.openai.com/v1/completions', false, $context);
echo $response;
?>
      

<?php
// Get user job title and skills
$job = $_POST['job'] ?? 'Software Engineer';
$skills = $_POST['skills'] ?? 'PHP, JavaScript, problem-solving';

// Build AI prompt
$data = [
  'prompt' => "Write a professional cover letter for a $job with skills in $skills.",
  'temperature' => 0.7,
  'max_tokens' => 250
];

// Set API context
$options = [
  'http' => [
    'header' => "Content-Type: application/json\r\nAuthorization: Bearer YOUR_API_KEY\r\n",
    'method' => 'POST',
    'content' => json_encode($data)
  ]
];

$context = stream_context_create($options);

// Call OpenAI API
$response = file_get_contents('https://api.openai.com/v1/completions', false, $context);

// Show result
echo $response;
?>
      

<?php
// Get theme input
$theme = $_POST['theme'] ?? 'love and loss';

// Create prompt for lyrics
$data = [
  'prompt' => "Write song lyrics about $theme in a poetic and emotional tone.",
  'temperature' => 0.9,
  'max_tokens' => 300
];

// Setup request
$options = [
  'http' => [
    'header' => "Content-Type: application/json\r\nAuthorization: Bearer YOUR_API_KEY\r\n",
    'method' => 'POST',
    'content' => json_encode($data)
  ]
];

$context = stream_context_create($options);

// Get lyrics
$response = file_get_contents('https://api.openai.com/v1/completions', false, $context);

// Output lyrics
echo $response;
?>
      

<?php
// Get user input industry
$industry = $_POST['industry'] ?? 'tech startup';

// Prompt for name ideas
$data = [
  'prompt' => "Suggest 5 creative and unique business names for a $industry.",
  'temperature' => 0.8,
  'max_tokens' => 100
];

// Setup HTTP request
$options = [
  'http' => [
    'header' => "Content-Type: application/json\r\nAuthorization: Bearer YOUR_API_KEY\r\n",
    'method' => 'POST',
    'content' => json_encode($data)
  ]
];

$context = stream_context_create($options);

// Fetch response
$response = file_get_contents('https://api.openai.com/v1/completions', false, $context);

// Show results
echo $response;
?>
      

<?php
// Receive slang message
$slang = $_POST['slang'] ?? 'YOLO and TBH, IDK what to do';

// Ask AI to translate it
$data = [
  'prompt' => "Translate this internet slang to normal English: $slang",
  'temperature' => 0.6,
  'max_tokens' => 120
];

// HTTP context settings
$options = [
  'http' => [
    'header' => "Content-Type: application/json\r\nAuthorization: Bearer YOUR_API_KEY\r\n",
    'method' => 'POST',
    'content' => json_encode($data)
  ]
];

$context = stream_context_create($options);

// Request translation
$response = file_get_contents('https://api.openai.com/v1/completions', false, $context);

// Output translation
echo $response;
?>
      

<?php
// Get science statement
$statement = $_POST['statement'] ?? 'Humans can breathe underwater without equipment';

// Request AI fact check
$data = [
  'prompt' => "Is this statement scientifically accurate? Explain why or why not: $statement",
  'temperature' => 0.5,
  'max_tokens' => 200
];

// Build HTTP request
$options = [
  'http' => [
    'header' => "Content-Type: application/json\r\nAuthorization: Bearer YOUR_API_KEY\r\n",
    'method' => 'POST',
    'content' => json_encode($data)
  ]
];

$context = stream_context_create($options);

// Get result
$response = file_get_contents('https://api.openai.com/v1/completions', false, $context);

// Display result
echo $response;
?>