ik krijg steeds dit probleem: Warning: Cannot modify header information - headers already sent by (output started at /srv/disk6/1501985/www/wmhelp.co.nf/nl/login/index.php:169) in /srv/disk6/1501985/www/wmhelp.co.nf/nl/login/index.php on line 190
Dit is mijn script:

<?php
session_start();
if (isset($_SESSION['ingelogd'])) {
	header('location: member.php');
} else {
	?>
    
	<!doctype html>
	<html>
	<head>
	<style>
	*{margin:0;padding:0;}
*:focus{outline:none;}

h2 {
margin: 0;
 font-size: 3em; 
 line-height: 1em; 
 margin-bottom: 0.5em
 }
 
h3 {
margin: 0;
 font-size: 2.25em;
 line-height: 1.3333333333333333333333333333333em;
 margin-bottom: 0.6667em
 }
 
h4 {
margin: 0; 
font-size: 1.5em; 
line-height: 1em; 
margin-bottom: 1em
}

h5 {
margin: 0;
 font-size: 1.3125em; 
 line-height: 1.1428571428571428571428571428571em;
 margin-bottom: 1.1428571428571428571428571428571em
 }

body{
	background:#e4a090;
	font-size: 16px;
	font-family: Arial, Helvetica, sans-serif;
}

.tel {
	color:#000
}


a {
	text-decoration:none
}


img {
	border:none
}


#ssssnake {
	display: block;
	text-align: left;
	background: #ed9780
}


#card {
    margin:1 , 1;
    position:relative;
	display:block; 
	width:350px; 
	min-height:120px; 
	background:#f8f8f5;
	margin:50px auto 0px;
}
#card2 {
    margin:1 , 1;
    position:relative;
	display:block; 
	width:350px; 
	min-height:10px; 
	background:#f8f8f5;
	margin:50px auto 0px;
}


header {
	text-align:center;
	display:block; 
	position:relative; 
	width:400px; 
	height:280px; 
	padding:60px 100px 0px;
	margin:0px auto
}


header h1 {
	display:block; 
	margin:10px 0px 0px 0px; 
	border:none;
	color:#8e3633;
	font-size:38px
}


header h2 {
	color: #ffffff; 
	font-size:38px
}


header h2:hover {
	text-decoration:underline; 
	color:#998dc9; 
	cursor:pointer
}


header h3 {
	display:block;
	font-size:18px;
	margin-top:10px
}

footer {
	width: 100%;
height:100%;
background:#000;
display:block;
float:left;
}

p {
color:#000000;
text-align:center;
padding:30px 0px 0px 0px;
}

#container {
	width: 100%;
	overflow:hidden;
	min-width:960px;
}
#left {
	float: left;
	width: 50%;
	display: inline;
}
#right{
	float:right;
	width: 50%;
	display: inline;
}
bericht {
	display:block; 
	width:100px; 
	height:100px;
}
	</style>
	<title>WMHelp</title>
	</head>
	<body>
	
	<?php
	if (isset($_POST['hidden'])) {
		include "mysql_connect.php";
		
		//variable
		$gebruikersnaam = mysql_real_escape_string($_POST['gebruikersnaam']);
		$wachtwoord = mysql_real_escape_string($_POST['wachtwoord']);
		
		$sql = "SELECT * FROM login1 WHERE gebruikersnaam='".$gebruikersnaam."' AND wachtwoord='".$wachtwoord."'";
		$query = mysql_query($sql);
		$num = mysql_num_rows($query);
	
		if($num == 1) {
			//Ingelogd
			$sql2 = "SELECT * FROM login1 WHERE gebruikersnaam='".$gebruikersnaam."' AND wachtwoord='".$wachtwoord."'";
			$query2 = mysql_query($sql2);
			$fetch = mysql_fetch_assoc($query2);
			
			$_SESSION['gebruikersnaam '] = $gebruikersnaam;
			$_SESSION['id'] = $fetch['id'];
			$_SESSION['ingelogd'] = true;
			exit(header('location: member.php'));
		} else {
			echo "Gebruikersnaam of wachtwoord is verkeerd";
		}
	
	
	} else {
		?>
        			
        <div id="card">		
		<form action="index.php" method="post">
			<div id="left">
			Gebruikersnaam:<br>
			<input type="text" name="gebruikersnaam" /><br>
			</div>
			<tr/>
			<div id="right">
			Wachtwoord:<br>
			<input type="password" name="wachtwoord" /><br>		
            </div>		
            <div id="left">	
			<input type="hidden" name="hidden">
			</div>
			<center><input type="submit" value=" Login " width="100">&nbsp;&nbsp; <a href="./register.php"><font color="red"> Registreer </font></a></center>
		</form>
		</div>
		<?php
	}
}
?>

</body>
</html>

Kunnen jullie mij verder helpen?
Groetjes Arne
Deze vraag komt (bijna) wekelijks voorbij op dit forum. Kwestie van zelf even zoeken naar een antwoord. Of gebruik Google. Levert je vele hits op. Ook de foutmelding op zich is al duidelijk.
Ik heb al aantal verschillende optie's geprobeerd voor het op te lossen maar het lukt niet, ik heb ook al op google gekeken maar zonder succes.
Dan heb je het niet goed gedaan.....

Begrijp je wat de foutmelding inhoudt?
Je mag geen enkele output hebben. Als ik naar je code kijk heb je een hele zooi output staan voor regel 190.
headers already sent ... (output started at .../login/index.php op regel 169)
Ga daar eens kijken.
goed, waar staat je header functie? Juist, regel 190.

Wat heb je ook al weer geleerd van die tutorial die ik je gaf? (want ik vraag me het echt af of je die wel hebt gelezen)

En wat heb jij dan op regel 1 - 169?

En wat betekend dat dus?

En als laatst, wat heb je ook alweer kunnen lezen in de conclusie van die tutorial? Hoe kon je je script ook alweer het beste structureren?
Dit is de correcte code:

<?php
session_start();
if (isset($_SESSION['ingelogd'])) {
	header('location: member.php');
} else {
	if (isset($_POST['hidden']) && $_SERVER['REQUEST_METHOD'] == 'POST') {
		include "mysql_connect.php";
		
		//variable
		$gebruikersnaam = mysql_real_escape_string($_POST['gebruikersnaam']);
		$wachtwoord = mysql_real_escape_string($_POST['wachtwoord']);
		
		$sql = "SELECT * FROM login1 WHERE gebruikersnaam='".$gebruikersnaam."' AND wachtwoord='".$wachtwoord."'";
		$query = mysql_query($sql);
		$num = mysql_num_rows($query);
	
		if($num == 1) {
			//Ingelogd
			$sql2 = "SELECT * FROM login1 WHERE gebruikersnaam='".$gebruikersnaam."' AND wachtwoord='".$wachtwoord."'";
			$query2 = mysql_query($sql2);
			$fetch = mysql_fetch_assoc($query2);
			
			$_SESSION['gebruikersnaam '] = $gebruikersnaam;
			$_SESSION['id'] = $fetch['id'];
			$_SESSION['ingelogd'] = true;
			header('location: member.php');
			exit;
		} else {
			echo "Gebruikersnaam of wachtwoord is verkeerd";
		}
		
	
	
	} else {
		?>
        			
        <div id="card">		
		<form action="http://wmhelp.co.nf/nl/login/index.php" method="post">
			<div id="left">
			Gebruikersnaam:<br>
			<input type="text" name="gebruikersnaam" /><br>
			</div>
			<tr/>
			<div id="right">
			Wachtwoord:<br>
			<input type="password" name="wachtwoord" /><br>		
            </div>		
            <div id="left">	
			<input type="hidden" name="hidden">
			</div>
			<center><input type="submit" value=" Login " width="100">&nbsp;&nbsp; <a href="./register.php"><font color="red"> Registreer </font></a></center>
		</form>
		</div>
		<?php
	}
	?>
		<!doctype html>
	<html>
	<head>
	<style>
	*{margin:0;padding:0;}
*:focus{outline:none;}

h2 {
margin: 0;
 font-size: 3em; 
 line-height: 1em; 
 margin-bottom: 0.5em
 }
 
h3 {
margin: 0;
 font-size: 2.25em;
 line-height: 1.3333333333333333333333333333333em;
 margin-bottom: 0.6667em
 }
 
h4 {
margin: 0; 
font-size: 1.5em; 
line-height: 1em; 
margin-bottom: 1em
}

h5 {
margin: 0;
 font-size: 1.3125em; 
 line-height: 1.1428571428571428571428571428571em;
 margin-bottom: 1.1428571428571428571428571428571em
 }

body{
	background:#e4a090;
	font-size: 16px;
	font-family: Arial, Helvetica, sans-serif;
}

.tel {
	color:#000
}


a {
	text-decoration:none
}


img {
	border:none
}


#ssssnake {
	display: block;
	text-align: left;
	background: #ed9780
}


#card {
    margin:1 , 1;
    position:relative;
	display:block; 
	width:350px; 
	min-height:120px; 
	background:#f8f8f5;
	margin:50px auto 0px;
}
#card2 {
    margin:1 , 1;
    position:relative;
	display:block; 
	width:350px; 
	min-height:10px; 
	background:#f8f8f5;
	margin:50px auto 0px;
}


header {
	text-align:center;
	display:block; 
	position:relative; 
	width:400px; 
	height:280px; 
	padding:60px 100px 0px;
	margin:0px auto
}


header h1 {
	display:block; 
	margin:10px 0px 0px 0px; 
	border:none;
	color:#8e3633;
	font-size:38px
}


header h2 {
	color: #ffffff; 
	font-size:38px
}


header h2:hover {
	text-decoration:underline; 
	color:#998dc9; 
	cursor:pointer
}


header h3 {
	display:block;
	font-size:18px;
	margin-top:10px
}

footer {
	width: 100%;
height:100%;
background:#000;
display:block;
float:left;
}

p {
color:#000000;
text-align:center;
padding:30px 0px 0px 0px;
}

#container {
	width: 100%;
	overflow:hidden;
	min-width:960px;
}
#left {
	float: left;
	width: 50%;
	display: inline;
}
#right{
	float:right;
	width: 50%;
	display: inline;
}
bericht {
	display:block; 
	width:100px; 
	height:100px;
}
	</style>
	<title>WMHelp</title>
	</head>
<?php
}
?>


</html>
Vind je dat correct? Je mist nu bijna alle belangrijke HTML...

Reageren