Hoşgeldin Misafir

Script İstek script isteği ödevi hakkınız neyse veririm

Kavkaz

11 Şub 2019
715 Mesaj

Aktiflik

Seviye

Deneyim

TIM / GÖREV:
al sana kodları


Kod:
<!DOCTYPE html>
<html lang="tr">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Matematik İşlem Uygulaması</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            margin: 0;
            padding: 0;
            background-color: #f4f4f4;
            display: flex;
            justify-content: center;
            align-items: center;
            height: 100vh;
        }
        .container {
            width: 60%;
            max-width: 800px;
            background-color: #ffffff;
            padding: 20px;
            border-radius: 10px;
            box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
            text-align: center;
            margin-top: 301px;
        }
        h1 {
            color: #4CAF50;
        }
        form {
            margin: 20px auto;
            padding: 20px;
            background: #f9f9f9;
            border: 2px solid #4CAF50;
            border-radius: 10px;
        }
        form label {
            font-weight: bold;
            display: block;
            margin-top: 10px;
            color: #333;
        }
        form input[type="text"] {
            width: 80%;
            padding: 10px;
            margin: 10px 0;
            border: 1px solid #ccc;
            border-radius: 5px;
        }
        form button {
            background-color: #4CAF50;
            color: white;
            padding: 10px 20px;
            border: none;
            border-radius: 5px;
            font-size: 16px;
            cursor: pointer;
        }
        form button:hover {
            background-color: #45a049;
        }
        .error {
            color: #ff0000;
            font-weight: bold;
        }
        .result {
            color: #2e8b57;
            font-size: 18px;
            font-weight: bold;
        }
        table {
            width: 100%;
            margin: 20px 0;
            border-collapse: collapse;
        }
        table th, table td {
            padding: 12px;
            border: 1px solid #ddd;
            text-align: center;
        }
        table th {
            background-color: #4CAF50;
            color: white;
        }
        ul {
            list-style: none;
            padding: 0;
        }
        ul li {
            margin: 5px 0;
            font-size: 16px;
        }
    </style>
</head>
<body>
    <div class="container">
        <h1>Matematik İşlem Uygulaması</h1>
        <form method="post">
            <label for="num1">Birinci Sayı:</label>
            <input type="text" id="num1" name="num1" required>
            <label for="num2">İkinci Sayı:</label>
            <input type="text" id="num2" name="num2" required>
            <label>İşlem Türü:</label>
            <input type="radio" id="add" name="operation" value="add" required>
            <label for="add">Toplama</label><br>
            <input type="radio" id="subtract" name="operation" value="subtract">
            <label for="subtract">Çıkarma</label><br>
            <input type="radio" id="multiply" name="operation" value="multiply">
            <label for="multiply">Çarpma</label><br>
            <input type="radio" id="divide" name="operation" value="divide">
            <label for="divide">Bölme</label><br><br>
            <button type="submit">Hesapla</button>
        </form>

        
        <h2>İstatistikler</h2>
        <table>
            <tr>
                <th>İstatistik</th>
                <th>Değer</th>
            </tr>
            <tr>
                <td>Toplam İşlem Sayısı</td>
                <td>2</td>
            </tr>
            <tr>
                <td>Toplama İşlemi</td>
                <td>0</td>
            </tr>
            <tr>
                <td>Çıkarma İşlemi</td>
                <td>2</td>
            </tr>
            <tr>
                <td>Çarpma İşlemi</td>
                <td>0</td>
            </tr>
            <tr>
                <td>Bölme İşlemi</td>
                <td>0</td>
            </tr>
        </table>

        <h2>Sunucu Bilgileri</h2>
        <ul>
            <li>IP Adresi: 176.88.125.243</li>
            <li>Sunucu Adı: www.kodend.com.tr</li>
            <li>Tarayıcı Bilgisi: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36</li>
        </ul>
    </div>
</body>
</html>
 

ZeroPulse

Bishkek
1 Ara 2018
1,140 Mesaj

Aktiflik

Seviye

Deneyim

TIM / GÖREV:
index.php olarak kaydedin ve sunucuya atın @eniskilinc06


PHP:
<?php
session_start();

if (!isset($_SESSION['total_operations'])) {
    $_SESSION['total_operations'] = 1; // Toplam işlem sayısı
    $_SESSION['addition_count'] = 0;
    $_SESSION['subtraction_count'] = 0;
    $_SESSION['multiplication_count'] = 0;
    $_SESSION['division_count'] = 0;
}

$user_ip = $_SERVER['REMOTE_ADDR'];

if ($_SERVER["REQUEST_METHOD"] == "POST") {
    // Kullanıcıdan gelen verileri al
    $num1 = $_POST['num1'];
    $num2 = $_POST['num2'];
    $operation = $_POST['operation'];

    if (is_numeric($num1) && is_numeric($num2)) {
        switch ($operation) {
            case 'add':
                $result = $num1 + $num2;
                $_SESSION['addition_count']++;
                break;
            case 'subtract':
                $result = $num1 - $num2;
                $_SESSION['subtraction_count']++;
                break;
            case 'multiply':
                $result = $num1 * $num2;
                $_SESSION['multiplication_count']++;
                break;
            case 'divide':
                if ($num2 != 0) {
                    $result = $num1 / $num2;
                    $_SESSION['division_count']++;
                } else {
                    $result = "Hata: Sıfıra bölünemez!";
                }
                break;
            default:
                $result = "Geçersiz işlem seçildi!";
                break;
        }
        $_SESSION['total_operations']++;
    } else {
        $result = "Lütfen geçerli sayılar girin!";
    }
}
?>

<!DOCTYPE html>
<html lang="tr">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Matematik İşlem Uygulaması</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            margin: 0;
            padding: 0;
            background-color: #f4f4f4;
            display: flex;
            justify-content: center;
            align-items: center;
            height: 100vh;
        }
        .container {
            width: 60%;
            max-width: 800px;
            background-color: #ffffff;
            padding: 20px;
            border-radius: 10px;
            box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
            text-align: center;
            margin-top: 301px;
        }
        h1 {
            color: #4CAF50;
        }
        form {
            margin: 20px auto;
            padding: 20px;
            background: #f9f9f9;
            border: 2px solid #4CAF50;
            border-radius: 10px;
        }
        form label {
            font-weight: bold;
            display: block;
            margin-top: 10px;
            color: #333;
        }
        form input[type="text"] {
            width: 80%;
            padding: 10px;
            margin: 10px 0;
            border: 1px solid #ccc;
            border-radius: 5px;
        }
        form button {
            background-color: #4CAF50;
            color: white;
            padding: 10px 20px;
            border: none;
            border-radius: 5px;
            font-size: 16px;
            cursor: pointer;
        }
        form button:hover {
            background-color: #45a049;
        }
        .error {
            color: #ff0000;
            font-weight: bold;
        }
        .result {
            color: #2e8b57;
            font-size: 18px;
            font-weight: bold;
        }
        table {
            width: 100%;
            margin: 20px 0;
            border-collapse: collapse;
        }
        table th, table td {
            padding: 12px;
            border: 1px solid #ddd;
            text-align: center;
        }
        table th {
            background-color: #4CAF50;
            color: white;
        }
        ul {
            list-style: none;
            padding: 0;
        }
        ul li {
            margin: 5px 0;
            font-size: 16px;
        }
    </style>
</head>
<body>
    <div class="container">
        <h1>Matematik İşlem Uygulaması</h1>
        <form method="post">
            <label for="num1">Birinci Sayı:</label>
            <input type="text" id="num1" name="num1" value="<?php echo isset($num1) ? $num1 : ''; ?>" required>
            <label for="num2">İkinci Sayı:</label>
            <input type="text" id="num2" name="num2" value="<?php echo isset($num2) ? $num2 : ''; ?>" required>
            <label>İşlem Türü:</label>
            <input type="radio" id="add" name="operation" value="add" <?php echo isset($operation) && $operation == 'add' ? 'checked' : ''; ?> required>
            <label for="add">Toplama</label><br>
            <input type="radio" id="subtract" name="operation" value="subtract" <?php echo isset($operation) && $operation == 'subtract' ? 'checked' : ''; ?>>
            <label for="subtract">Çıkarma</label><br>
            <input type="radio" id="multiply" name="operation" value="multiply" <?php echo isset($operation) && $operation == 'multiply' ? 'checked' : ''; ?>>
            <label for="multiply">Çarpma</label><br>
            <input type="radio" id="divide" name="operation" value="divide" <?php echo isset($operation) && $operation == 'divide' ? 'checked' : ''; ?>>
            <label for="divide">Bölme</label><br><br>
            <button type="submit">Hesapla</button>
        </form>

        <div class="result">
            <?php
            if (!empty($result)) {
                echo "<h2>Sonuç: $result</h2>";
            }
            ?>
        </div>

        <h2>İstatistikler</h2>
        <table>
            <tr>
                <th>İstatistik</th>
                <th>Değer</th>
            </tr>
            <tr>
                <td>Toplam İşlem Sayısı</td>
                <td><?php echo $_SESSION['total_operations']; ?></td>
            </tr>
            <tr>
                <td>Toplama İşlemi</td>
                <td><?php echo $_SESSION['addition_count']; ?></td>
            </tr>
            <tr>
                <td>Çıkarma İşlemi</td>
                <td><?php echo $_SESSION['subtraction_count']; ?></td>
            </tr>
            <tr>
                <td>Çarpma İşlemi</td>
                <td><?php echo $_SESSION['multiplication_count']; ?></td>
            </tr>
            <tr>
                <td>Bölme İşlemi</td>
                <td><?php echo $_SESSION['division_count']; ?></td>
            </tr>
        </table>

        <h2>Sunucu Bilgileri</h2>
        <ul>
            <li>IP Adresi: <?php echo $user_ip; ?></li>
            <li>Sunucu Adı: www.matrushkasoft.com.tr</li>
        </ul>
    </div>
</body>
</html>