CoolFace
Apppublic

bagas89/edusync-dashboard-student-faculty-manager

sourceHugging Faceupdated 11mo agoView on Hugging Face
0likes
edit_student.php48 linesDownload Raw Back to root
1```php2<?php3require_once 'config.php';4 5$student = null;6if (isset($_GET['id'])) {7    $id = $conn->real_escape_string($_GET['id']);8    $query = "SELECT * FROM mahasiswa WHERE id_mahasiswa = '$id'";9    $result = $conn->query($query);10    if ($result->num_rows > 0) {11        $student = $result->fetch_assoc();12    } else {13        header("Location: students.php");14        exit();15    }16}17 18if ($_SERVER['REQUEST_METHOD'] == 'POST') {19    $id = $conn->real_escape_string($_POST['id']);20    $nim = $conn->real_escape_string($_POST['nim']);21    $nama = $conn->real_escape_string($_POST['nama']);22    // Other fields similar to add_student.php23 24    $query = "UPDATE mahasiswa SET 25              nim = '$nim',26              nama = '$nama',27              jenis_kelamin = '$jenis_kelamin',28              jurusan = '$jurusan',29              tanggal_lahir = '$tanggal_lahir',30              alamat = '$alamat',31              no_hp = '$no_hp',32              email = '$email',33              tahun_masuk = '$tahun_masuk',34              status = '$status'35              WHERE id_mahasiswa = '$id'";36    37    if ($conn->query($query)) {38        header("Location: students.php?success=1");39        exit();40    } else {41        $error = "Error: " . $conn->error;42    }43}44?>45 46<!DOCTYPE html>47<!-- Similar to add_student.php but with pre-filled values -->48```