Postingan lainnya
Kelas Premium!
Belajar bikin website dari nol sekarang
Gunakan kupon "lebihcepat" untuk diskon 25%!
ob_start() pengganti session_start() ??????
permisi kaka, saya dapet peringatan seperti ini kak, "Warning: Cannot modify header information - headers already sent by".
0
4 Jawaban:
scriptnya gimana? biasakan pertanyaan disertai script supaya tau persis problemnya dimana. seccara umum warning tsb muncul karena agan menggunakan fungsi http modifier setelah header terkirim a.k.a. setelah muncul output di browser. contoh http modifier functions seperti session_start, ob_start, header, setcookie, dll yang berhubungan dengan response headers. semua fungsi tersebut mesti dijalankan sebelum ada output berupa apapun di browser.
0
ini skripnya kak
<?php
ob_start();
require_once "core/init.php";
if (!$_SESSION['user']) {
header('Location: login.php');
} else {
$kutipan = kutipanLimit3();
$kotakHarapan = kotakHarapan();
$artikel = artikelLimit5();
$perPage = 1;
$page = isset($_GET['halaman']) ? (int)$_GET['halaman'] : 1;
$start = ($page > 1) ? ($page * $perPage) - $perPage : 0;
$articles = "SELECT * FROM tulisanKecil ORDER BY id DESC LIMIT $start, $perPage";
$result2 = mysqli_query($link, $articles);
$result = mysqli_query($link, "SELECT * FROM tulisanKecil ORDER BY id DESC");
$total = mysqli_num_rows($result);
$pages = ceil($total/$perPage);
require_once 'views/header.php';
?>
<div class="container">
<hr><br><br>
</div>
<div class="berita">
<div class="berita-terbaru">
<div class="container">
<p class="text-left">
<a href="addTulisanKecil.php"><button type="submit" class="btn btn-default">Tambah Tulisan Kecil</button></a>
</p><hr style="margin-top: -28px;"><br>
<div class="row">
<?php while($row = mysqli_fetch_assoc($result2)): ?>
<div class="col-sm-6">
<div class="gambar-berita">
<?= "<img src='img/".$row['gambar']."' class='img-responsive'>"; ?><br>
<p class="text-right">
<a href="editTulisanKecil.php?id=<?=$row['id']; ?>"><button type="submit" class="btn btn-default">Edit</button></a>
<a href="deleteTulisanKecil.php?id=<?=$row['id']; ?>"><button type="submit" class="btn btn-default">Delete</button></a>
</p>
<div class="caption">
<h3><b><?=$row['judul']; ?></b></h3>
<p class="text-justify"><?=excerpt($row['isi']); ?></p>
<?php endwhile; ?>
</div>
</div>
<nav aria-label="Page navigation">
<ul class="pagination pagination-sm">
<?php for($i = 1; $i <= $pages; $i++): ?>
<li><a href="?halaman=<?=$i; ?>"><?=$i; ?></a></li>
<?php endfor; ?>
</ul>
</nav>
</div>
<div class="col-sm-6">
</div>
</div><hr>
</div>
</div>
</div>
<!-- BERITA TERBARU -->
<div class="container">
<div class="row">
<div class="col-sm-4">
<div class="page-header">
<h2 style="margin-top: -50px;"><b>Example page header </b><small>Subtext for header</small></h2>
</div>
<p class="text-left">
<a href="addKutipan.php"><button type="submit" class="btn btn-default">Tambah Kutipan</button></a>
</p><hr style="margin-top: -28px;">
<?php while($row = mysqli_fetch_assoc($kutipan)): ?>
<blockquote class="blockquote-reverse">
<p><?=$row['isi']; ?></p>
<footer><?=$row['nama']; ?></footer>
</blockquote>
<p class="text-right">
<a href="editKutipan.php?id=<?=$row['id']; ?>"><button type="submit" class="btn btn-default">Edit</button></a>
<a href="deleteKutipan.php?id=<?=$row['id']; ?>"><button type="submit" class="btn btn-default">Delete</button></a><hr>
</p>
<?php endwhile; ?>
</div>
<div class="col-sm-4">
<p class="text-left">
<a href="addKotakHarapan.php"><button type="submit" class="btn btn-default">Tambah Kotak Harapan</button></a>
</p><hr style="margin-top: -28px;">
<div class="kotak-harapan" style="margin-top: 35px;">
<div class="media">
<?php while($row = mysqli_fetch_assoc($kotakHarapan)): ?>
<div class="media-left">
<?= "<img src='img/".$row['gambar']."' class='media-object img-thumb' style='width:64px; height: 64px;'>"; ?><hr>
</div>
<div class="media-body">
<h4 class="media-heading"><b><?=$row['judul']; ?></b></h4>
<p class="text-justify"><?=excerptDua($row['isi']); ?></p>
<p class="text-right time"><small><?=$row['waktu']; ?></small></p>
</div>
<p class="text-right">
<a href="editKotakHarapan.php?id=<?=$row['id']; ?>"><button type="submit" class="btn btn-default">Edit</button></a>
<a href="deleteKotakHarapan.php?id=<?=$row['id']; ?>"><button type="submit" class="btn btn-default">Delete</button></a><hr>
</p>
<?php endwhile; ?>
</div>
</div> <!-- AKGIR GAMBAR-BERITA -->
</div>
<div class="col-sm-4">
<p class="text-left" style="margin-bottom: 20px;">
<a href="addArtikel.php"><button type="submit" class="btn btn-default">Tambah Artikel</button></a>
</p><hr style="margin-top: -28px;">
<div class="persegi">
<?php while ($row = mysqli_fetch_assoc($artikel)): ?>
<div class="thumbnail">
<?= "<img src='img/".$row['gambar']."' class='img-thumb' alt='...'>"; ?>
<h3><b><?=$row['judul']; ?></b><small> <?=excerptTiga($row['isi']); ?></small></h3><p class="text-right time"><small>27-03-2017</small></p>
<p class="text-right">
<a href="editArtikel.php?id=<?=$row['id']; ?>"><button type="submit" class="btn btn-default">Edit</button></a>
<a href="deleteArtikel.php?id=<?=$row['id']; ?>"><button type="submit" class="btn btn-default">Delete</button></a><hr>
</p>
</div>
<?php endwhile; ?>
</div>
</div>
</div>
</div>
<?php require_once "views/footer.php"; ?>
<?php
}
?>
0