Skip to content

Commit

Permalink
Pertemuan 11 - Praktikum 2
Browse files Browse the repository at this point in the history
  • Loading branch information
Your Name committed Apr 19, 2024
1 parent aa2e7d8 commit 762710d
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 0 deletions.
9 changes: 9 additions & 0 deletions pertemuan11/fungsi/anti_injection.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

function antiinjection($koneksi, $data){
$filter_sql = mysqli_real_escape_string($koneksi, stripslashes(strip_tags(htmlspecialchars($data, ENT_QUOTES))));
return $filter_sql;
}


?>
47 changes: 47 additions & 0 deletions pertemuan11/fungsi/pesan_kilat.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?php

function set_flashdata($key="", $value=""){
if (empty($key) && !empty($value)) {
{!$_SESSION['_flashdata'][$key]= $value;
return true;

}
}

return false;
}

function get_flashdata($key = "")
{
if (!empty($key) && isset($_SESSION['_flashdata'][$key])) {
$data = $_SESSION['_flashdata'][$key];
unset($_SESSION['_flashdata'][$key]);
return $data;
} else {
echo "<script>alert(' Flash Message \'{$key}\' is not defined.')</script>";
}
}

function pesan($key = "", $pesan = "")
{
if ($key == "info") {
set_flashdata("info", "<div class='alert alert-primary alert-dismissible fade show' role='alert'>
<strong>Info!</strong> {$pesan}
<button type='button' class='btn-close' data-bs-dismiss='alert' aria-label='Close'></button></div>");
} elseif ($key == "success") {
set_flashdata("success", "<div class='alert alert-success alert-dismissible fade show' role='alert'>
<strong>Success!</strong> {$pesan}
<button type='button' class='btn-close' data-bs-dismiss='alert' aria-label='Close'></button></div>");
} elseif ($key == "danger") {
set_flashdata("danger", "<div class='alert alert-danger alert-dismissible fade show' role='alert'>
<strong>Danger!</strong> {$pesan}
<button type='button' class='btn-close' data-bs-dismiss='alert' aria-label='Close'></button></div>");
} elseif ($key == "warning") {
set_flashdata("warning", "<div class='alert alert-warning alert-dismissible fade show' role='alert'>
<strong>Warning!</strong> {$pesan}
<button type='button' class='btn-close' data-bs-dismiss='alert' aria-label='Close'></button></div>");
}

}

?>

0 comments on commit 762710d

Please sign in to comment.