mirror of
https://github.com/dyzulk/raisen-app.git
synced 2026-01-26 13:22:00 +07:00
first commit
This commit is contained in:
85
act/ubah.php
Normal file
85
act/ubah.php
Normal file
@@ -0,0 +1,85 @@
|
||||
<?php
|
||||
session_start();
|
||||
|
||||
if( !isset($_SESSION["login"]) ) {
|
||||
header("Location: login.php");
|
||||
exit;
|
||||
}
|
||||
|
||||
require '../functions.php';
|
||||
|
||||
// ambil data di URL
|
||||
$id = $_GET["id"];
|
||||
|
||||
// query data mahasiswa berdasarkan id
|
||||
$mhs = query("SELECT * FROM mahasiswa WHERE id = $id")[0];
|
||||
|
||||
|
||||
// cek apakah tombol submit sudah ditekan atau belum
|
||||
if( isset($_POST["submit"]) ) {
|
||||
|
||||
// cek apakah data berhasil diubah atau tidak
|
||||
if( ubah($_POST) > 0 ) {
|
||||
echo "
|
||||
<script>
|
||||
alert('data berhasil diubah!');
|
||||
document.location.href = 'index.php';
|
||||
</script>
|
||||
";
|
||||
} else {
|
||||
echo "
|
||||
<script>
|
||||
alert('data gagal diubah!');
|
||||
document.location.href = 'index.php';
|
||||
</script>
|
||||
";
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Ubah data mahasiswa</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Ubah data mahasiswa</h1>
|
||||
|
||||
<form action="" method="post" enctype="multipart/form-data">
|
||||
<input type="hidden" name="id" value="<?= $mhs["id"]; ?>">
|
||||
<input type="hidden" name="gambarLama" value="<?= $mhs["gambar"]; ?>">
|
||||
<ul>
|
||||
<li>
|
||||
<label for="nrp">NRP : </label>
|
||||
<input type="text" name="nrp" id="nrp" required value="<?= $mhs["nrp"]; ?>">
|
||||
</li>
|
||||
<li>
|
||||
<label for="nama">Nama : </label>
|
||||
<input type="text" name="nama" id="nama" value="<?= $mhs["nama"]; ?>">
|
||||
</li>
|
||||
<li>
|
||||
<label for="email">Email :</label>
|
||||
<input type="text" name="email" id="email" value="<?= $mhs["email"]; ?>">
|
||||
</li>
|
||||
<li>
|
||||
<label for="jurusan">Jurusan :</label>
|
||||
<input type="text" name="jurusan" id="jurusan" value="<?= $mhs["jurusan"]; ?>">
|
||||
</li>
|
||||
<li>
|
||||
<label for="gambar">Gambar :</label> <br>
|
||||
<img src="../img/<?= $mhs['gambar']; ?>" width="40"> <br>
|
||||
<input type="file" name="gambar" id="gambar">
|
||||
</li>
|
||||
<li>
|
||||
<button type="submit" name="submit">Ubah Data!</button>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
</form>
|
||||
|
||||
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user