HEX
Server: nginx/1.24.0
System: Linux webserver-one 6.8.0-101-generic #101-Ubuntu SMP PREEMPT_DYNAMIC Mon Feb 9 10:15:05 UTC 2026 x86_64
User: www-data (33)
PHP: 8.4.18
Disabled: NONE
Upload Files
File: /srv/www/rectt-csmcri.res.in/public_html/view_primary.php
<?php
session_start();
include_once 'sites/config/config.php';


// Check if user is logged in
if (!isset($_SESSION['registered'])) {
    header("location:login.php");
}
if ($_SESSION["app_submitted"] ==  "True") {
    header("location:success.php");
    exit;
}

// if (!isset($_SESSION['application_id'])) {
//     header("location:login.php");
// }

if (!isset($_SESSION['user_id'])) {
    die("Access denied. Please login first.");
}

$user_id = $_SESSION['user_id'];

// Connect to database
// $conn = new mysqli($host, $username, $password, $db_name);
// if ($conn->connect_error) {
//     die("Connection failed: " . $conn->connect_error);
// }

// Fetch primary details
$query = "SELECT * FROM primary_details WHERE user_id = ?";
$stmt = $conn->prepare($query);
$stmt->bind_param("i", $user_id);
$stmt->execute();
$result = $stmt->get_result();
$primary = $result->fetch_assoc();

if (!$primary) {
    die("No data found for this user.");
}

// Fetch relatives if any
$relatives = [];
if ($primary['relative_in_csir'] === 'Yes') {
    $rel_stmt = $conn->prepare("SELECT * FROM relatives WHERE user_id = ?");
    $rel_stmt->bind_param("i", $user_id);
    $rel_stmt->execute();
    $rel_result = $rel_stmt->get_result();
    while ($row = $rel_result->fetch_assoc()) {
        $relatives[] = $row;
    }
}
?>

<!DOCTYPE html>
<html>

<head>
    <div style="background-color: #f0f0f0; padding: 10px; margin-bottom: 15px; border: 1px solid #ccc;">

        <title>View Primary Details</title>
        <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css">
        <style>
            body {
                font-family: Arial, sans-serif;
                padding: 20px;
            }

            table {
                border-collapse: collapse;
                width: 100%;
                margin-bottom: 30px;
            }

            th,
            td {
                border: 1px solid #ddd;
                padding: 8px;
                vertical-align: top;
            }

            th {
                background-color: #f2f2f2;
            }

            h2 {
                margin-top: 40px;
            }
        </style>
</head>

<body>
    <h1>Primary Details</h1>
    <table>
        <tr>
            <th>SSC Name</th>
            <td><?= htmlspecialchars($primary['ssc_name']) ?></td>
        </tr>
        <tr>
            <th>Name Changed</th>
            <td><?= htmlspecialchars($primary['has_name_changed']) ?></td>
        </tr>
        <?php if ($primary['has_name_changed'] == 'Yes'): ?>
            <tr>
                <th>New Name</th>
                <td><?= htmlspecialchars($primary['new_name']) ?></td>
            </tr>
        <?php endif; ?>
        <tr>
            <th>Mother's Name</th>
            <td><?= htmlspecialchars($primary['mother_name']) ?></td>
        </tr>
        <tr>
            <th>Father's Name</th>
            <td><?= htmlspecialchars($primary['father_name']) ?></td>
        </tr>
        <tr>
            <th>Date of Birth</th>
            <td><?= htmlspecialchars($primary['dob']) ?></td>
        </tr>
        <tr>
            <th>Age</th>
            <td><?= htmlspecialchars($primary['age']) ?></td>
        </tr>
        <tr>
            <th>Place of Birth</th>
            <td><?= htmlspecialchars($primary['place_ob']) ?></td>
        </tr>
        <tr>
            <th>Citizenship</th>
            <td><?= htmlspecialchars($primary['citizenship']) ?></td>
        </tr>
        <tr>
            <th>Gender</th>
            <td><?= htmlspecialchars($primary['gender']) ?></td>
        </tr>
        <tr>
            <th>Religion</th>
            <td><?= htmlspecialchars($primary['religion']) ?></td>
        </tr>
        <tr>
            <th>Disability</th>
            <td><?= htmlspecialchars($primary['disability']) ?></td>
        </tr>
        <tr>
            <th>Disability (Hearing)</th>
            <td><?= htmlspecialchars($primary['disability_hearing'] === 'hearing' ? 'Yes' : $primary['disability_hearing']) ?></td>
        </tr>
        <tr>
            <th>Disability (Walking)</th>
            <td><?= htmlspecialchars($primary['disability_walking'] === 'walking' ? 'Yes' : $primary['disability_walking']) ?></td>
        </tr>
        <tr>
            <th>Disability (Multiple)</th>
            <td><?= htmlspecialchars($primary['disability_multiple'] === 'multiple' ? 'Yes' : $primary['disability_multiple']) ?></td>
        </tr>
        <tr>
            <th>Category</th>
            <td><?= htmlspecialchars($primary['category']) ?></td>
        </tr>
        <tr>
            <th>Ex-Servicemen</th>
            <td><?= htmlspecialchars($primary['ex_servicemen']) ?></td>
        </tr>
        <?php if ($primary['ex_servicemen'] === 'Yes'): ?>
            <tr>
                <th>Service Duration</th>
                <td><?= "{$primary['service_years']} years, {$primary['service_months']} months, {$primary['service_days']} days" ?></td>
            </tr>
        <?php endif; ?>
        <tr>
            <th>Government Employee</th>
            <td><?= htmlspecialchars($primary['gov_employee']) ?></td>
        </tr>
        <?php if ($primary['gov_employee'] === 'Yes'): ?>
            <tr>
                <th>Govt Organization</th>
                <td><?= htmlspecialchars($primary['gov_organization']) ?></td>
            </tr>
            <tr>
                <th>Govt Post</th>
                <td><?= htmlspecialchars($primary['gov_post']) ?></td>
            </tr>
        <?php endif; ?>
        <tr>
            <th>CSIR Employee</th>
            <td><?= htmlspecialchars($primary['csir_employee']) ?></td>
        </tr>
        <?php if ($primary['csir_employee'] === 'Yes'): ?>
            <tr>
                <th>CSIR Institute</th>
                <td><?= htmlspecialchars($primary['csir_lab']) ?></td>
            </tr>
            <tr>
                <th>CSIR Designation</th>
                <td><?= htmlspecialchars($primary['csir_designation']) ?></td>
            </tr>
        <?php endif; ?>
        <tr>
            <th>Marital Status</th>
            <td><?= htmlspecialchars($primary['marital_status']) ?></td>
        </tr>
        <tr>
            <th>Staying Abroad</th>
            <td><?= htmlspecialchars($primary['staying_abroad']) ?></td>
        </tr>
        <tr>
            <th>Correspondence Address</th>
            <td>
                <?= htmlspecialchars($primary['corr_house']) ?>, <?= htmlspecialchars($primary['corr_city']) ?>,
                <?= htmlspecialchars($primary['corr_district']) ?>, <?= htmlspecialchars($primary['corr_state']) ?> - <?= htmlspecialchars($primary['corr_pincode']) ?>
            </td>
        </tr>
        <tr>
            <th>Permanent Address</th>
            <td>
                <?= htmlspecialchars($primary['perm_house']) ?>, <?= htmlspecialchars($primary['perm_city']) ?>,
                <?= htmlspecialchars($primary['perm_district']) ?>, <?= htmlspecialchars($primary['perm_state']) ?> - <?= htmlspecialchars($primary['perm_pincode']) ?>
            </td>
        </tr>
        <tr>
            <th>Email</th>
            <td><?= htmlspecialchars($primary['email']) ?></td>
        </tr>
        <tr>
            <th>Secondary Email</th>
            <td><?= htmlspecialchars($primary['secondary_email']) ?></td>
        </tr>
        <tr>
            <th>Mobile</th>
            <td><?= htmlspecialchars($primary['mobile']) ?></td>
        </tr>
        <tr>
            <th>Alternate Mobile</th>
            <td><?= htmlspecialchars($primary['alt_mobile']) ?></td>
        </tr>
        <tr>
            <th>Relative in CSIR</th>
            <td><?= htmlspecialchars($primary['relative_in_csir']) ?></td>
        </tr>
    </table>

    <?php if (!empty($relatives)): ?>
        <h2>CSIR Relatives</h2>
        <table>
            <tr>
                <th>Name</th>
                <th>Post</th>
                <th>Lab/Institute</th>
                <th>Relationship</th>
            </tr>
            <?php foreach ($relatives as $relative): ?>
                <tr>
                    <td><?= htmlspecialchars($relative['relative_name']) ?></td>
                    <td><?= htmlspecialchars($relative['post']) ?></td>
                    <td><?= htmlspecialchars($relative['lab_institute']) ?></td>
                    <td><?= htmlspecialchars($relative['relationship']) ?></td>
                </tr>
            <?php endforeach; ?>
        </table>
    <?php endif; ?>
    <center>
        <a href="main.php" class="btn btn-primary">Back to Main</a>
    </center>
</body>

</html>

<?php
$conn->close();
?>