Tolong pilih kategori sesuai, jenis posting (diskusi atau bukan) dan sertakan tag/topik yang sesuai seperti komputer, java, php, mysql, dll. Promosi atau posting tidak pada tempatnya akan kami hapus!
- Bagi Anda yang ingin mendaftar, baca link berikut:
http://diskusiweb.com/discussion/50491/how-to-registrasi-diskusiweb-com-baca-ini-terlebih-dahulu
- Cara menyisipkan kode program supaya tampil rapi dan terformat dengan baik di diskusiweb.com: http://www.diskusiweb.com/discussion/50415/cara-menyisipkan-kode-program-di-diskusiweb-com
- Cara posting gambar/image di post Anda: http://www.diskusiweb.com/discussion/47345/cara-menyisipkan-menyertakan-image-pada-posting/p1

bgmana cara mengatasi Warning: session_start(): Cannot send session cache limiter ?

Saya membuat form pendaftaran anggota, dan mengalami error seperti ini :
Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /home/u987361841/public_html/register/birthdate.php:106) in /home/u987361841/public_html/register/index.php on line 191 Warning: Cannot modify header information - headers already sent by (output started at /home/u987361841/public_html/register/birthdate.php:106) in /home/u987361841/public_html/register/index.php on line 193
Bagaimana cara mengatasi error tersebut ?
mohon bantuannya^^
Terima Kasih ^^
Berikut script PHP saya :

<?php
$root = $_SERVER['DOCUMENT_ROOT'];
include "$root/resource/mysql_connect.php";
if (isset($_POST['register'])) {
date_default_timezone_set("Asia/Jakarta");
$day = date("l");  $date = date("d - F - Y");  $time = date("h:i:s A"); $tanggal = $_POST['tanggal']; $bulan = $_POST['bulan']; $tahun = $_POST['tahun']; $ip_address = $_SERVER['REMOTE_ADDR']; $useragent = $_SERVER['HTTP_USER_AGENT']; $name = ucwords($_POST['name']); $birthloc = $_POST['birthloc'];  $birthdate = "$tanggal - $bulan  - $tahun";
$agama = $_POST['agama'];
$gender = $_POST['gender'];
$email = $_POST['email'];
$address = $_POST['address'];
$phone = $_POST['phone'];
$username = $_POST['username'];
$password = $_POST['password'];
$cpassword = $_POST['cpassword'];
$true_access = isset($name)&&isset($birthloc)&&isset($birthdate)&&isset($agama)&&isset($gender)&&isset($email)&&isset($address)&&isset($phone)&&isset($username)&&isset($password)&&isset($cpassword)&&$password==$cpassword&&preg_match("/^[a-zA-Z0-9.]*$/",$username)&&filter_var($email, FILTER_VALIDATE_EMAIL)&&$check_username==0&&$check_email==0&&$chek_phone==0;
    // Logs file for security \\
$logs_file = "$root/history/register_logs.txt";
$handle = fopen($logs_file, 'a');
fwrite($handle, "==========================================");
fwrite($handle, "\n");
fwrite($handle, "IP Address : $ip_address");
fwrite($handle, "\n");
fwrite($handle, "UserAgent : $useragent");
fwrite($handle, "\n");
fwrite($handle, "Date Submitted : $day, $date $time");
fwrite($handle, "\n");
fwrite($handle, "Session Username : $session_username");
fwrite($handle, "\n");
fwrite($handle, "==========================================");
fwrite($handle, "\n");
fwrite($handle, "\n");
fclose($handle);
$sql_a = mysql_query("SELECT * FROM admin_info WHERE Username='$username';");
$check_username = mysql_num_rows($sql_a);
$sql_b = mysql_query("SELECT * FROM admin_info WHERE E_Mail='$email';");
$check_email = mysql_num_rows($sql_b);
$sql_c = mysql_query("SELECT * FROM admin_info WHERE Nomor_HP='$phone';");
$check_phone = mysql_num_rows($sql_c);
if (empty($name)) {
echo "<script>alert('Nama belum diisi !')</script>";
} else
if (empty($birthloc)) {
echo "<script>alert('Tempat lahir belum diisi !')</script>";
} else
if (empty($birthdate)) {
echo "<script>alert('Tanggal lahir belum diisi !')</script>";
} else
if (empty($agama)) {
echo "<script>alert('Agama belum diisi !')</script>";
} else
if (empty($gender)) {
echo "<script>alert('Jenis kelamin belum diisi !')</script>";
} else
if (empty($email)) {
echo "<script>alert('E-Mail belum diisi !')</script>";
} else
if (empty($address)) {
echo "<script>alert('Alamat belum diisi !')</script>";
} else
if (empty($phone)) {
echo "<script>alert('Nomor HP belum diisi !')</script>";
} else
if (empty($username)) {
echo "<script>alert('Username belum diisi !')</script>";
} else
if (empty($password)) {
echo "<script>alert('Password belum diisi !')</script>";
} else
if (empty($cpassword)) {
echo "<script>alert('Konfirmasi Password belum diisi !')</script>";
} else
if (strlen($username)<=6) {
echo "<script>alert('Username terlalu pendek, minimal 6 karakter !')</script>";
} else
if (strlen($username)>=20) {
echo "<script>alert('Username terlalu panjang, maksimal 20 karakter !')</script>";
} else
if (strlen($password)<=6) {
echo "<script>alert('Password terlalu pendek, minimal 6 karakter !')</script>";
} else
if (strlen($password>=50)) {
echo "<script>alert('Password terlalu panjang, maksimal 50 karakter')</script>";
} else
if ($password!=$cpassword) {
echo "<script>alert('Konfirmasi password tidak sama !')</script>";
} else
if (!preg_match("/^[a-zA-Z0-9.]*$/",$username)) {   
echo "<script>alert('Username tidak boleh mengandung karakter khusus !')</script>";
} else
if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {   
echo "<script>alert('E-Mail salah !')</script>";
} else
if ($check_username>0) {
echo "<script>alert('Username sudah digunakan !')</script>";
} else
if ($check_email>0) {
echo "<script>alert('E-Mail sudah digunakan !')</script>";
} else
if ($chek_phone>0) {
echo "<script>alert('Nomor HP sudah digunakan !')</script>";
} else
if ($true_access) {
          mysql_query("INSERT INTO `admin_info` (`id`, `Nama`, `Jenis_Kelamin`, `Tanggal_Lahir`, `Tempat_Lahir`, `Agama`, `Alamat`, `E_Mail`, `Nomor_HP`, `Username`, `Password`) VALUES ('1', '$name', '$gender', '$birthdate', '$birthloc', '$agama', '$address', '$email', '$phone', '$username', '$password');");
          session_start();
          $_SESSION['email'] = $email;
          header("register_success.php"); }}
?>

Comments

  • kan pesan error nya jelas ...

    session_start() itu kagak bakal bisa jalan kalo sudah ada output ke browser
    server sudah mengirim header ke browser client
    jadi kagak bisa diubah lagi header nya

    di pesan error juga disebut dimana output itu sudah nungul ...

    Warning: session_start():
    Cannot send session cache limiter - headers already sent
    (output started at /home/u987361841/public_html/register/birthdate.php:106)
    in /home/u987361841/public_html/register/index.php on line 191

    Warning:
    Cannot modify header information - headers already sent by
    (output started at /home/u987361841/public_html/register/birthdate.php:106)
    in /home/u987361841/public_html/register/index.php on line 193

    solusinya ?
    ya jangan ada output yg dikirim ke browser kalo mau session_start() nya jalan

    tuh di ...
    /home/u987361841/public_html/register/index.php on line 191
    /home/u987361841/public_html/register/index.php on line 193
    ada apa ?
    itu pasti sudah output semua
    entah echo, atau apapun ...



    bisa elo idupin output buffering
    semua output ditampung dulu di server sampai selesai urusan
    baru dikirim sekaligus ke client
    tapi ini cuma nambah-nambahin beban server yg harus mengalokasikan space memori buat menampung output di server
  • edited June 2016
    line 191 : session_start();
    line 193 : header("register_success.php");


    pada line 193 headernya lupa kasih "location", habis itu saya benerin jadi header("location:register_success.php"),
    malah keluar begini :

    Service Temporarily Unavailable

    The server closed the connection without sending any data.

    The server is temporarily unable to service your request due to
    maintenance downtime or capacity problems.

    Due to heavy load on the server, connections may be temporarily
    blocked from locations that fetch an unusually high number of
    pages.

    We apologize for the inconvenience.


    kenapa ya?

  • yg terakhir itu karena alamat url kagak ada


    sori, gw kebalik ...
    output sudah keluar itu di :
    output started at /home/u987361841/public_html/register/birthdate.php:106
    2-2 nya sama, session_start() maupun header()
    sudah ada output ke browser di situ
Sign In or Register to comment.