HELP Warning: Cannot modify header information
Ik heb een website gemaakt voor mijn school project die het eerst gewoon goed deed maar nu dus niet meer.
Als men een bestelling wil doen krijg je de volgende foutmelding:
Warning: Cannot modify header information - headers already sent by (output started at /home/century/domains/centurydeals.nl/public_html/order.php:1) in /home/century/domains/centurydeals.nl/public_html/order.php on line 58
Ik heb de website ook offline en op een andere online locatie laten testen en daar werkt het wel gewoon. Hoe kan dit :O
Toevoeging op 27/03/2013 10:48:20:
php Code:
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<?php if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
$insertSQL = sprintf("INSERT INTO gegevens (voornaam, achternaam, adres, postcode, woonplaats, telefoon, email, aantal) VALUES (%s, %s, %s, %s, %s, %s, %s, %s)",
GetSQLValueString($_POST['voornaam'], "text"),
GetSQLValueString($_POST['achternaam'], "text"),
GetSQLValueString($_POST['adres'], "text"),
GetSQLValueString($_POST['postcode'], "text"),
GetSQLValueString($_POST['woonplaats'], "text"),
GetSQLValueString($_POST['telefoon'], "text"),
GetSQLValueString($_POST['email'], "text"),
GetSQLValueString($_POST['aantal'], "text"));
mysql_select_db($database_con_centurydeals, $con_centurydeals);
$Result1 = mysql_query($insertSQL, $con_centurydeals) or die(mysql_error());
$insertGoTo = "bedankt.php";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s",$insertGoTo));
}
?>
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
$insertSQL = sprintf("INSERT INTO gegevens (voornaam, achternaam, adres, postcode, woonplaats, telefoon, email, aantal) VALUES (%s, %s, %s, %s, %s, %s, %s, %s)",
GetSQLValueString($_POST['voornaam'], "text"),
GetSQLValueString($_POST['achternaam'], "text"),
GetSQLValueString($_POST['adres'], "text"),
GetSQLValueString($_POST['postcode'], "text"),
GetSQLValueString($_POST['woonplaats'], "text"),
GetSQLValueString($_POST['telefoon'], "text"),
GetSQLValueString($_POST['email'], "text"),
GetSQLValueString($_POST['aantal'], "text"));
mysql_select_db($database_con_centurydeals, $con_centurydeals);
$Result1 = mysql_query($insertSQL, $con_centurydeals) or die(mysql_error());
$insertGoTo = "bedankt.php";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s",$insertGoTo));
}
?>
Gewijzigd op 27/03/2013 10:56:09 door Fabian Doddema
Ik gok een witregel op lijn 1 van order.php.
Ik heb het nu aangepast zoals hierboven te zien is maar helpt nog niks
Ergens moet er HTML worden geechoed voor de header() functie. In order.php zelf of in een bestand dat word geinclude of required.
<!DOCTYPE html PUBLIC >
<html xml:lang="en" >
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta name="author" content="Century Deals" />
<meta name="keywords" content="Century Deals" />
<meta name="description" content="Century Deals" />
<meta name="robots" content="all" />
<title>Century Deals | Bestellen</title>
<meta name="keywords" content="Veilig, Verkeer, Staysharp, Centurydeals, century, deals, slaapalarm" />
<style type="text/css" media="all">
@import "global.css";
</style>
</head>
<body>
<div id="wrapper">
<div id="header">
<center>
<img src="img/centurydealio.jpg" width="524" height="100" alt="centurydeals" /></center>
</div>
<div id="navi">
<ul>
<li><a href="index.html">Homepage</a></li>
<li><a href="nieuws.html">Nieuws</a></li>
<li><a href="staysharp.html">Stay Sharp</a></li>
<li><a href="order.php">Bestellen</a></li>
<li><a href="overons.html">Wie zijn wij</a></li>
<li><a href="offerte.php">Offerte aanvragen</a></li>
<li><a href="contact.html">Klantenservice</a></li>
</ul>
</div>
<div id="subnavi">
<ul>
<li class="active"><a href="#"></a></li>
<li><a href="#"></a></li>
<li><a href="#"></a></li>
<li><a href="#"></a></li>
</ul>
</div>
<div id="main">
<div class="ic"></div>
<div id="content">
<h2> Welkom in onze shop</h2>
<p> Op dit moment richten wij ons volledig op de StaySharp. De StaySharp is een klein electronisch apparaat wat u achter uw oor kunt plaatsen. Wanneer u nu dreigt in een slaap houding te vallen zal het apparaat een een piep geven waardoor het praktisch onmogelijk is om achter het stuur in slaap te vallen. Wilt u ook graag veilig achter het stuur tijdens een zakenreis, vakantie of gewoon een lange dag op pad? Dan is de SaySharp het product voor u!</p>
<p>Wij bieden de Staysharp nu aan voor slechts <strong>€5.00 </strong>, exclusief verzendkosten! Dit is natuurljik geen geld voor een product dat u en anderen op de weg veiliger maakt! </p>
<p>Bestel hem dus nu!</p>
<p>Voor meer informatie over de StaySharp kun u <a href="staysharp.html">HIER</a> kijken</p>
<p> </p>
<script type="text/javascript">
var ultimateshow=new Array()
ultimateshow[0]=['img/staysharp.jpg', ]
ultimateshow[1]=['img/staysharp 2.jpg',]
ultimateshow[2]=['img/staysharp 3.jpg',]
var slidewidth="300px"
var slideheight="261px"
var slidecycles="continous"
var randomorder="no"
var preloadimages="yes"
var slidebgcolor='white'
var slidedelay=3000
var ie=document.all
var dom=document.getElementById
var curcycle=0
if (preloadimages=="yes"){
for (i=0;i<ultimateshow.length;i++){
var cacheimage=new Image()
cacheimage.src=ultimateshow[0]
}
}
var currentslide=0
function randomize(targetarray){
ultimateshowCopy=new Array()
var the_one
var z=0
while (z<targetarray.length){
the_one=Math.floor(Math.random()*targetarray.length)
if (targetarray[the_one]!="_selected!"){
ultimateshowCopy[z]=targetarray[the_one]
targetarray[the_one]="_selected!"
z++
}
}
}
if (randomorder=="yes")
randomize(ultimateshow)
else
ultimateshowCopy=ultimateshow
function rotateimages(){
curcycle=(currentslide==0)? curcycle+1 : curcycle
ultcontainer='<center>'
if (ultimateshowCopy[currentslide][1]!="")
ultcontainer+='<a href="'+ultimateshowCopy[currentslide][1]+'" target="'+ultimateshowCopy[currentslide][2]+'">'
ultcontainer+='<img src="'+ultimateshowCopy[currentslide][0]+'" border="0">'
if (ultimateshowCopy[currentslide][1]!="")
ultcontainer+='</a>'
ultcontainer+='</center>'
if (ie||dom)
crossrotateobj.innerHTML=ultcontainer
if (currentslide==ultimateshow.length-1) currentslide=0
else currentslide++
if (curcycle==parseInt(slidecycles) && currentslide==0)
return
setTimeout("rotateimages()",slidedelay)
}
if (ie||dom)
document.write('<div id="slidedom" style="width:'+slidewidth+';height:'+slideheight+'; background-color:'+slidebgcolor+'"></div>')
function start_slider(){
crossrotateobj=dom? document.getElementById("slidedom") : document.all.slidedom
rotateimages()
}
if (ie||dom)
window.onload=start_slider
</script>
<form id="form1" name="form1" method="POST" action="">
<p> </p>
<p>Voornaam:<br />
<label for="voornaam"></label>
<input type="text" name="voornaam" id="voornaam" />
</p>
<p>Achternaam:
<br />
<input type="text" name="achternaam" id="achternaam" />
</p>
<p>Adres:
<br />
<input type="text" name="adres" id="adres" />
</p>
<p>Postcode:
<br />
<input type="text" name="postcode" id="postcode" />
</p>
<p>Woonplaats:
<br />
<input type="text" name="woonplaats" id="woonplaats" />
</p>
<p>Telefoon: <br />
<input type="text" name="telefoon" id="telefoon" />
</p>
<p>E-mail:
<br />
<input type="text" name="email" id="email" />
</p>
<p>Aantal:
<br />
<input type="text" name="aantal" id="aantal" />
</p>
<p>Gaat u akkoord met de <a href="voorwaarden.html">voorwaarden</a></p>
<p> <span id="sprycheckbox1">
<input type="checkbox" name="checkbox1" id="checkbox1" />
<label for="checkbox1">Akkoord</label>
<span class="checkboxRequiredMsg">U moet akkoord gaan met de voorwaarden.</span></span></p>
<p>
<input type="submit" name="button" id="button" value="Submit" />
</p>
<input type="hidden" name="MM_insert" value="form1" />
</form>
</form>
</form>
</p>
</div>
<div id="news">
<h1>Nieuws</h1>
<div class="item">
<p><small>03.02.2013</small><br/>
<b>Century Deals op tv!</b><br>
Binnenkort zijn we op TV te bewonderen.. <a href="nieuws.html">» Lees meer..</a></p>
</div>
<div class="item">
<p><small>29.01.2013</small><br/>
<b>Opendag Campus Winschoten</b><br>
Century Deals was aanwezig op de opendag van..<br/><a href="nieuws.html">» Lees meer..</a></p>
</div>
<div class="item">
<p><small>29.11.2012</small><br/>
<b>Lancering nieuwe website</b><br>
De nieuwe website is gelanceerd!<br/> <a href="nieuws.html">» Lees meer..</a></p>
</div>
</div>
</div>
<div id="footer">
<p>© Copyright 2012 Century Deals | Alle rechten voorbehouden | Design by <a href="www.centurydeals.tk" target="_blank">Century Deals</a></p>
</div>
<div class="cleaner"></div>
</div>
</body>
</html>
Is het gewoon niet de B-O-M, de Byte-Order-Mark die roet in het eten gooit?
Ik zou niet weten wat dat is :O
De foutmelding die je krijgt is er 1 die erg regelmatig verschijnt.
Oorzaak: voor (in dit geval regel 58) is er output.
Dat kan een spatie, witregel, B-O-M, HTML-code, .... zijn.
Je zult zelf je code moeten controleren/nalopen.
Het was inderdaad BOM -.-
Bedankt voor de hulp!