leonsuke

Mirip dengan yang punyaku. :\

Sep 18th, 2016
208
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.79 KB | None | 0 0
  1. <?php
  2. require_once "dbconn.php";
  3.  
  4. $upload_dir = "../../assets/foto";
  5. $kata_sandi = isset($_POST["kata_sandi"]) ? $_POST["kata_sandi"] : "FALSE";
  6. $kata_sandi2 = isset($_POST["kata_sandi2"]) ? $_POST["kata_sandi2"] : "FALSE";
  7. $id_pengguna = isset($_POST["id_pengguna"]) ? $_POST["id_pengguna"] : "FALSE";
  8. $foto = isset($_FILES["foto"]["name"]) ? $_FILES["foto"]["name"] : "FALSE";
  9.  
  10. if ($kata_sandi == $kata_sandi2) {
  11. if (empty($kata_sandi2)) {
  12. try {
  13. $sql1 = $con->prepare("UPDATE tbl_pengguna SET foto = ? WHERE id_pengguna = ?");
  14. $sql1->bindParam(1, $foto);
  15. $sql1->bindParam(2, $id_pengguna);
  16.  
  17. if ($sql1->execute()) {
  18. move_uploaded_file($_FILES['foto']['tmp_name'], "$upload_dir/$foto");
  19. header("location: http://tasselearning.ac.id/e-learning/mahasiswa/index.php?file=gantidatadiri");
  20. } else {
  21. // Kode FALSE
  22. }
  23. } catch (PDOException $e) {
  24. echo $e->getMessage();
  25. }
  26. } else {
  27. try {
  28. $new_katasandi2 = password_hash($kata_sandi2, PASSWORD_DEFAULT);
  29. $sql1 = $con->prepare("UPDATE tbl_pengguna SET kata_sandi = ? WHERE id_pengguna = ?");
  30. $sql1->bindParam(1, $new_katasandi2);
  31. $sql1->bindParam(2, $id_pengguna);
  32.  
  33. if ($sql1->execute()) {
  34. header("location: http://tasselearning.ac.id/e-learning/mahasiswa/index.php?file=gantidatadiri");
  35. } else {
  36. // Kode FALSE
  37. }
  38. } catch (PDOException $e) {
  39. echo $e->getMessage();
  40. }
  41. }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment