Reply
cannot add header information
Old 05-24-2008, 11:33 AM cannot add header information
Junior Talker

Posts: 1
Name: beqy
hello every body.
i have a problem with my script, but i don know where location/code error position.
when i run the script (transaksivalidasi.php) i got error comment
Warning: Cannot add header information - headers already sent by (output started at c:\apache\htdocs\rekayasa\display\inc.kode_pembeli .php:32) in c:\apache\htdocs\rekayasa\display\transaksivalidas i.php on line 164

this is script from file transaksivalidasi.php

<?php
require_once('../koneksi/inc.connect.php');
if (is_numeric($txt_nama) || empty($txt_nama))
{
//pengecekan pada kolom nama
echo "<div align=center>";
echo "<b>Nama anda belum dimasukan!</b><br><br>";
echo "<a href=javascript:history.go(-1)>&lt; kembali</a>";
echo "</div>";
exit();
}
else if (is_numeric($txt_email) || empty($txt_email))
{
//pengecekan pada kolom email
echo "<div align=center>";
echo "<b>Email anda belum dimasukan!</b><br><br>";
echo "<a href=javascript:history.go(-1)>&lt; kembali</a>";
echo "</div>";
exit();
}
else if (is_numeric($txt_alamat) || empty($txt_alamat))
{
//pengecekan pada kolom alamat
echo "<div align=center>";
echo "<b>Alamat anda belum dimasukan!</b><br><br>";
echo "<a href=javascript:history.go(-1)>&lt; kembali</a>";
echo "</div>";
exit();
}
else if (is_numeric($txt_kota) || empty($txt_kota))
{
//pengecekan pada kolom kota
echo "<div align=center>";
echo "<b>Kota anda belum dimasukan!</b><br><br>";
echo "<a href=javascript:history.go(-1)>&lt; kembali</a>";
echo "</div>";
exit();
}
else if (! is_numeric($txt_kdpost) || empty($txt_kdpost))
{
//pengecekan pada kolom kd pos
echo "<div align=center>";
echo "<b>Kd pos anda belum dimasukan!</b><br><br>";
echo "<a href=javascript:history.go(-1)>&lt; kembali</a>";
echo "</div>";
exit();
}
else if (is_numeric($txt_propinsi) || empty($txt_propinsi))
{
//pengecekan pada kolom propinsi
echo "<div align=center>";
echo "<b>Propinsi anda belum dimasukan!</b><br><br>";
echo "<a href=javascript:history.go(-1)>&lt; kembali</a>";
echo "</div>";
exit();
}
else if (is_numeric($txt_negara) || empty($txt_negara))
{
//pengecekan pada kolom negara
echo "<div align=center>";
echo "<b>Negara anda belum dimasukan!</b><br><br>";
echo "<a href=javascript:history.go(-1)>&lt; kembali</a>";
echo "</div>";
exit();
}
else if (! is_numeric($txt_telprumah) || empty($txt_telprumah))
{
//pengecekan pada kolom telp rumah
echo "<div align=center>";
echo "<b>Telp rumah anda belum dimasukan!</b><br><br>";
echo "<a href=javascript:history.go(-1)>&lt; kembali</a>";
echo "</div>";
exit();
}
else if (! is_numeric($txt_rek) || empty($txt_rek))
{
//pengecekan pada kolom negara
echo "<div align=center>";
echo "<b>Nomor Rekening anda belum dimasukan!</b><br><br>";
echo "<a href=javascript:history.go(-1)>&lt; kembali</a>";
echo "</div>";
exit();
}
else if (! is_numeric($txt_pin) || empty($txt_pin))
{
//pengecekan pada kolom negara
echo "<div align=center>";
echo "<b>Nomor PIN anda belum dimasukan!</b><br><br>";
echo "<a href=javascript:history.go(-1)>&lt; kembali</a>";
echo "</div>";
exit();
}
else
{
$iplocal=$REMOTE_ADDR;
$tglsekarang=date('Y-m-d');
$IDPlocal="$tglsekarang-$iplocal";

//mengecek keberadaan data anggota dalam tabel pembeli
$sql_cekpems="select kd_pembeli, iplocal
from pembeli
where iplocal='$IDPlocal'
and kd_pembeli='$kdpembeli'";



$exe_cekpems=mysql_query($sql_cekpems,$connect)
or die (" Gagal mengecek data ".mysql_error());
$pemada=mysql_num_rows($exe_cekpems);
if ($pemsada >= 1)
{
//apabila data yang dimasukan sudah ada
echo "<div align=center>";
echo "<b>Data yang anda masukan telah didaftarkan</b><br><br>";
echo "<pree> Nama: $txt_nama <br>
Email: $txt_email <br>
Alamat: $txt_alamat <br>
</pree>";
echo "<a href=javascript:history.go(-1)>&lt; Kembali</a>";
echo "</div>";
exit();
}
else if($pemsada < 1)
{
// apabila data yang dimasukan tidak ada dalam tabel pembeli
// fungsinya apabila user melakukan refresh, maka akan gagal
// mengecek validasi nomor rekening
$sql_aut=mysql_query("select VB.no_rek
from v_bank VB
where VB.no_rek='$txt_rek'
and VB.pin_rek='$txt_pin'");
$cekada=mysql_num_rows($sql_aut);
if ($cekada >= 1)
{
//jika rekening ada atau sukses dicek
require("inc.kode_pembeli.php");
$kdpembeli=$kd_pembeli;

$tanggal=date('Y-m-d');
$sql_simanggota="insert into pembeli set
kd_pembeli='$kd_pembeli',
iplocal='$IDPlocal',
nama='$txt_nama',
alamat='$txt_alamat',
kota='$txt_kota',
propinsi='$txt_propinsi',
negara='$txt_negara',
kdpost='$txt_kdpost',
email='$txt_email',
telp_rumah='$txt_telprumah',
telp_hp='$txt_telphp',
no_rek='$txt_rek'";

$exe_simanggota=mysql_query($sql_simanggota,$conne ct)
or die ("gagal menyimpan kekantong".mysql_error());

if ($exe_simanggota)
{
// jika penyimpan data anggota sukses

require_once('../koneksi/inc.connect.php');
include "transferbarang.php";
header("location: fakturbeli.php?IDP=$IDPlocal&nofaktur=$no_faktur") ;
exit();
}
else
{
// jika penyimpan data anggota gagal
echo "data tidak dapat disimpan";
}
}
else
{
// jika pengecekan validasi rekening gagal
echo "<div align=center>";
echo "<b>Nomor Rekening/PIN tidak sesuai!</b><br>";
echo "<a href=javascript:history.go(-1)>&lt; kembali</a>";
echo "</div>";
exit();
}
}
}

?>

this is script file inc.kode_pembeli.php

<?php
require_once('../koneksi/inc.connect.php');
$sql_cek="select count(*) from pembeli";
$hs_cek=mysql_query($sql_cek)
or die ("Query SQL salah! ".mysql_error());
$br_cek=mysql_fetch_row($hs_cek);
$jumlah=$br_cek [0];
$jumlah=$jumlah +1;
$panjang=strlen($jumlah);
switch($panjang)
{
case 1:
{
$kd_pembeli="U00".$jumlah;
break;
}
case 2:
{
$kd_pembeli="U0".$jumlah;
break;
}
case 3:
{
$kd_pembeli="U".$jumlah;
break;
}
}
?>

i hope you all can help me.
thank you.
toples is offline
Reply With Quote
View Public Profile
 
When You Register, These Ads Go Away!
     
Old 05-24-2008, 06:55 PM Re: cannot add header information
King Spam Talker

Posts: 1,067
I did not see the error with a quick look over what you posted.

This error is usually caused by a session_start () being called after html has been sent to the browser. One of your includes must have that statement. When you find it, it must come before any html.
colbyt is offline
Reply With Quote
View Public Profile
 
Old 05-24-2008, 07:12 PM Re: cannot add header information
PeachyJuice's Avatar
Skilled Talker

Latest Blog Post:
One Month Progress Report
Posts: 94
Name: Michele T.
Location: Ny, Ny
I see the error. It has to do with:
PHP Code:
if ($exe_simanggota)
{
// jika penyimpan data anggota sukses 

require_once('../koneksi/inc.connect.php');
include 
"transferbarang.php";
header("location: fakturbeli.php?IDP=$IDPlocal&nofaktur=$no_faktur") ;
exit(); 

You can't change the header location after the page HTML has been loaded. I can't understand the language, but if you want the page to redirect here I suggest using an html meta tag which looks something like this:

<meta http-equiv="refresh" content="2;url=http://google.com">

You'd have to use php to get the url to look right of course. But that would be the easiest fix for what you seem to be doing (which I can't exactly tell because I can't read the language).
PeachyJuice is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to cannot add header information
 

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.14779 seconds with 13 queries