0

I am having error in proseslogin.php

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/sloki/user/masterli/sites/masterlink.co.id/www/cgoods/proseslogin.php:3) in /home/sloki/user/masterli/sites/masterlink.co.id/www/cgoods/proseslogin.php on line 6

Di sini blok aplikasi setelah login dilakukan
Anda berhasil menjalankan!
Warning: Cannot modify header information - headers already sent by (output started at /home/sloki/user/masterli/sites/masterlink.co.id/www/cgoods/proseslogin.php:3) in /home/sloki/user/masterli/sites/masterlink.co.id/www/cgoods/proseslogin.php on line 36

proseslogin.php

<?php

// start session
session_start(); 

$username = $_POST['username'];
$password = $_POST['password'];
$login = isset($_POST['login']) ? $_POST['login'] : false;

//function
function periksa ($username, $password){
		if (($username=="*****") and ($password=="*******")){
			return true;
		}else{
			return false;
		}
	}	
	
// cek		
if (periksa($username, $password)) {
		$login=true;	
}
else {
		echo "User ID atau password salah!";
		
		header("Location: http://localhost/Masterlink/cgoods/index.php");
}
if ($login) {
	echo "<br>Di sini blok aplikasi setelah login dilakukan";
	echo "<br>Anda berhasil menjalankan!";
	
	// buat session username
	$_SESSION['username'] = $username;	
	header("Location: http://localhost/Masterlink/cgoods/admin.php");
	exit();
}


?>

line 6: session_start();

The error appears after I enter my username and password.

2
Contributors
5
Replies
6
Views
5 Years
Discussion Span
Last Post by davy_yg
0

Remove the unwanted empty lines in the top of the page. According to your code I am referring to line 1 and line 2

0

This error appears after I enter username and password.

Di sini blok aplikasi setelah login dilakukan
Anda berhasil menjalankan!
Warning: Cannot modify header information - headers already sent by (output started at /home/sloki/user/masterli/sites/masterlink.co.id/www/cgoods/proseslogin.php:29) in /home/sloki/user/masterli/sites/masterlink.co.id/www/cgoods/proseslogin.php on line 34


proseslogin.php

<?php

// start session
session_start(); 

$username = $_POST['username'];
$password = $_POST['password'];
$login = isset($_POST['login']) ? $_POST['login'] : false;

//function
function periksa ($username, $password){
		if (($username=="*****") and ($password=="******")){
			return true;
		}else{
			return false;
		}
	}	
	
// cek		
if (periksa($username, $password)) {
		$login=true;	
}
else {
		echo "User ID atau password salah!";
		
		header("Location: http://www.masterlink.co.id/cgoods/index.php");
}
if ($login) {
	echo "<br>Di sini blok aplikasi setelah login dilakukan";
	echo "<br>Anda berhasil menjalankan!";
	
	// buat session username
	$_SESSION['username'] = $username;	
	header("Location: http://www.masterlink.co.id/cgoods/admin.php");
	exit();
}


?>

Line 34: header("Location: http://www.masterlink.co.id/cgoods/admin.php");

0

Ahh right..
That happens because you have used an "echo" before the "header()". Remove the "echo"s

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.