belajar login di PHP

Assalamualaikum saya mau bertanya , ada sedikit masalah ketika saya login dengan kode berikut

 <?php
  //apakah tombol submit sudah ditekan atau belum
if(isset($_POST["submit"]) ){
//cek username & password
	if($_POST["username"] == "admin" && $_POST["password"] == "1234"){

		//jika benar, redirect ke halaman admin
		header("Location : admin.php");
		exit;
	} else {
		//jika salah, tampilkan pesan kesalahan
		$error = true;
	}

}

?>

<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>login Admin</title>
</head>
<body>

	<h1>Login Admin</h1>

	<?php if(isset($error)) : ?>
		<p style="color:red ; font-style: italic;"  >username / password salah !</p>
	<?php endif; ?>

	<ul>
		<form action="" method="post">
			<li>
				<label for="username">Username :</label>
				<input type="text" name="username" id="username">
			</li>
			<li>
				<label for="password">password :</label>
				<input type="password"name="password" id="password">
			</li>
			<li>
				<button type="submit" name="submit">Login</button>
			</li>
		</form>
	</ul>
</body>
</html>

setelah saya isikan form nya dengan benar maka malah tampil seperti ini di web browsernya

 Server error!
The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there was an error in a CGI script.

If you think this is a server error, please contact the webmaster.

Error 500
localhost
Apache/2.4.29 (Win32) OpenSSL/1.0.2l PHP/7.1.11
avatar ErwinPrasetyo
@ErwinPrasetyo

36 Kontribusi 4 Poin

Diperbarui 4 tahun yang lalu

4 Jawaban:

Jawaban Terpilih

Penulisannya salah

 header("location : admin.php");

ganti

 header("location: admin.php");

setelah "location" gak usah "spasi" langsung ":"

Selamat Belajar.. (^_^)/...

avatar ciloxz
@ciloxz

284 Kontribusi 139 Poin

Dipost 6 tahun yang lalu

Tanggapan

Bener² makasih buat @ciloxz. Aku hampir mau guling²an gegara salah spasi doang, Masyaallah

makasih mas cilox

avatar ErwinPrasetyo
@ErwinPrasetyo

36 Kontribusi 4 Poin

Dipost 6 tahun yang lalu

ok dek erwin hehe..

avatar ciloxz
@ciloxz

284 Kontribusi 139 Poin

Dipost 6 tahun yang lalu

trimakasih mas. saya kira xampp saya bermasalah

avatar gepe98
@gepe98

1 Kontribusi 0 Poin

Dipost 4 tahun yang lalu

Login untuk ikut Jawaban