PHP Cookies

Gestart doorAntonn15 reacties74 weergaven

16 berichten · pagina 1 van 2

Antonn

Lid · Topicstarter

Berichten
8.649
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Njam! Ik ben bezig met cookies. Alleen lukt dit niet cry
[COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/setcookie"]setcookie[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"name"[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #DD0000]"loll"[/COLOR][COLOR= #007700],[/COLOR] [URL="http://www.php.net/time"]time[/URL][COLOR= #007700]()+([/COLOR][COLOR= #0000BB]60[/COLOR] [COLOR= #007700]*[/COLOR] [COLOR= #0000BB]60[/COLOR] [COLOR= #007700]*[/COLOR] [COLOR= #0000BB]24[/COLOR] [COLOR= #007700]*[/COLOR] [COLOR= #0000BB]365[/COLOR] [COLOR= #007700]*[/COLOR] [COLOR= #0000BB]1[/COLOR][COLOR= #007700]));[/COLOR] ?>


Hij geeft deze error:

Warning: Cannot modify header information - headers already sent by (output started at /home/zillax/domains/zillax.nl/public_html/nieuws/index.php:20) in /home/zillax/domains/zillax.nl/public_html/nieuws/index.php on line 50


en maakt geen cookie aan.
Help sadley
Mvg, ik
0
Berichten
10.421
Reputatie
4
Punten
0,00
Lid sinds
Laatst gezien
Je hebt er HTML of een witregel bovenaan staan op lijn 20, en dat mag niet.

Je gaat me niet vertellen dat je op Google niks hebt gevonden?
0
Antonn

Lid · Topicstarter

Berichten
8.649
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Aarclay schreef:
Je hebt er HTML of een witregel bovenaan staan op lijn 20, en dat mag niet.

Je gaat me niet vertellen dat je op Google niks hebt gevonden? Jhaah emo
Het moet helemaal bovenaan net zoals session_start??

toevoeging op 25 maart 2012, 15:46:39:
Spoiler tonen
[COLOR= #0000BB]<?php
$bericht_sql[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"SELECT keuring, titel, author, datum, kortbericht, bericht FROM nieuws WHERE id="[/COLOR][COLOR= #007700].[/COLOR][URL="http://www.php.net/mysql_real_escape_string"]mysql_real_escape_string[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_GET[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]id[/COLOR][COLOR= #007700]]).[/COLOR][COLOR= #DD0000]""[/COLOR][COLOR= #007700]);[/COLOR]
[URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/mysql_num_rows"]mysql_num_rows[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$bericht_sql[/COLOR][COLOR= #007700]) ==[/COLOR] [COLOR= #0000BB]0[/COLOR][COLOR= #007700]) {[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]Dit nieuwsbericht bestaat niet![/COLOR][COLOR= #007700];
}[/COLOR][URL="http://www.php.net/else"]else[/URL][COLOR= #007700]{[/COLOR]
[COLOR= #0000BB]$bericht[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_fetch_assoc"]mysql_fetch_assoc[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$bericht_sql[/COLOR][COLOR= #007700]);[/COLOR]
[URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$bericht[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]keuring[/COLOR][COLOR= #007700]] !=[/COLOR] [COLOR= #DD0000]1[/COLOR][COLOR= #007700]) {[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]Dit nieuwsbericht is nog niet gekeurd![/COLOR][COLOR= #007700];
}[/COLOR][URL="http://www.php.net/elseif"]elseif[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$bericht[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]keuring[/COLOR][COLOR= #007700]] ==[/COLOR] [COLOR= #DD0000]2[/COLOR][COLOR= #007700]) {[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]Dit nieuwsbericht is afgekeurd![/COLOR][COLOR= #007700];
}[/COLOR][URL="http://www.php.net/else"]else[/URL][COLOR= #007700]{[/COLOR]
[COLOR= #0000BB]$author[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_fetch_assoc"]mysql_fetch_assoc[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"SELECT naam, mail FROM leden WHERE id="[/COLOR][COLOR= #007700].[/COLOR][URL="http://www.php.net/mysql_real_escape_string"]mysql_real_escape_string[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$bericht[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]author[/COLOR][COLOR= #007700]]).[/COLOR][COLOR= #DD0000]""[/COLOR][COLOR= #007700]));[/COLOR]
?>
<table style="width: 100%;">
<tbody>
<tr>
<td style="font-weight: bold;">Titel</td>
<td>[COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] htmlspecialchars[COLOR= #007700]([/COLOR][URL="http://www.php.net/stripslashes"]stripslashes[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$bericht[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]titel[/COLOR][COLOR= #007700]]));[/COLOR] ?></td>
</tr>
<tr>
<td style="font-weight: bold;">Auteur</td>
<td><a href="mailto: [COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$author[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]mail[/COLOR][COLOR= #007700]];[/COLOR] ?>">[COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] htmlspecialchars[COLOR= #007700]([/COLOR][URL="http://www.php.net/stripslashes"]stripslashes[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$author[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]naam[/COLOR][COLOR= #007700]]));[/COLOR] ?></a></td>
</tr>
<tr>
<td style="font-weight: bold;">Datum</td>
<td>[COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$bericht[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]datum[/COLOR][COLOR= #007700]];[/COLOR] ?></a></td>
</tr>
<tr>
<td style="font-weight: bold;">Bericht</td>
<td><strong>[COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] htmlspecialchars[COLOR= #007700]([/COLOR][URL="http://www.php.net/stripslashes"]stripslashes[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$bericht[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]kortbericht[/COLOR][COLOR= #007700]]));[/COLOR] ?></strong><br /><br />[COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] htmlspecialchars[COLOR= #007700]([/COLOR][URL="http://www.php.net/stripslashes"]stripslashes[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$bericht[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]bericht[/COLOR][COLOR= #007700]]));[/COLOR] ?></td>
</tr>
</tbody>
</table>
<br />
<form name="form1" action="" method="post">
<table style="width: 100%;">
<tbody>
<tr>
<td style="font-weight: bold;">
Naam
</td>
<td style="font-weight: bold;">
<input type="text" name="naam" maxlenght="120"[COLOR= #0000BB]<?php[/COLOR]
[URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/isset"]isset[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_COOKIE[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]name[/COLOR][COLOR= #007700]]) && ![/COLOR][URL="http://www.php.net/empty"]empty[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_COOKIE[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]name[/COLOR][COLOR= #007700]])) {[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000] value="[/COLOR][COLOR= #007700].[/COLOR]htmlspecialchars[COLOR= #007700]([/COLOR][URL="http://www.php.net/addslashes"]addslashes[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_COOKIE[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]name[/COLOR][COLOR= #007700]])).[/COLOR][COLOR= #DD0000]"[/COLOR][COLOR= #007700];
}[/COLOR]
?>>[COLOR= #0000BB]<?php[/COLOR]
[URL="http://www.php.net/setcookie"]setcookie[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"name"[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #DD0000]"loll"[/COLOR][COLOR= #007700],[/COLOR] [URL="http://www.php.net/time"]time[/URL][COLOR= #007700]()+([/COLOR][COLOR= #0000BB]60[/COLOR] [COLOR= #007700]*[/COLOR] [COLOR= #0000BB]60[/COLOR] [COLOR= #007700]*[/COLOR] [COLOR= #0000BB]24[/COLOR] [COLOR= #007700]*[/COLOR] [COLOR= #0000BB]365[/COLOR] [COLOR= #007700]*[/COLOR] [COLOR= #0000BB]1[/COLOR][COLOR= #007700]));[/COLOR]

[URL="http://www.php.net/print_r"]print_r[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_COOKIE[/COLOR][COLOR= #007700]);[/COLOR]
?> 
</td>
</tr>
</tbody>
</table>
</form>
[COLOR= #0000BB]<?php[/COLOR]
[COLOR= #007700]}
}[/COLOR]
?>
Nog niet af emo
0
Berichten
10.421
Reputatie
4
Punten
0,00
Lid sinds
Laatst gezien
Vriendje schreef:
Eerdere citaten tonen
Aarclay schreef:
Je hebt er HTML of een witregel bovenaan staan op lijn 20, en dat mag niet.
Je gaat me niet vertellen dat je op Google niks hebt gevonden? Jhaah emo

Het moet helemaal bovenaan net zoals session_start??
Beter zoeken voortaan...
1e hit had ik al raak.

En ja, dat klopt.

Als het goed is zal print_r($_COOKIE); nog niks aangeven.
Pas op de volgende pagina gebeurt dit.
0
Antonn

Lid · Topicstarter

Berichten
8.649
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Aarclay schreef:
Eerdere citaten tonen
Vriendje schreef:
Eerdere citaten tonen
Aarclay schreef:
Je hebt er HTML of een witregel bovenaan staan op lijn 20, en dat mag niet.
Je gaat me niet vertellen dat je op Google niks hebt gevonden? Jhaah emo

Het moet helemaal bovenaan net zoals session_start??
Beter zoeken voortaan...
1e hit had ik al raak.

En ja, dat klopt.

Als het goed is zal print_r($_COOKIE); nog niks aangeven.
Pas op de volgende pagina gebeurt dit.
Hij geeft hele zooi cookies weer van me andere systemen emo
Maar ik snap niet hoe ik het nu oplos?
0
Berichten
10.421
Reputatie
4
Punten
0,00
Lid sinds
Laatst gezien
Dat zeg ik toch?

Er mag GEEN HTML of witruimte voor staan.
0
Antonn

Lid · Topicstarter

Berichten
8.649
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Aarclay schreef:
Dat zeg ik toch?
Er mag GEEN HTML of witruimte voor staan.

Thanks yes_new
0
Antonn

Lid · Topicstarter

Berichten
8.649
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Nieuw probleem:

[COLOR= #0000BB]<?php[/COLOR]
[URL="http://www.php.net/if"]if[/URL] [COLOR= #007700]([/COLOR][COLOR= #0000BB]$_SERVER[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]REQUEST_METHOD[/COLOR][COLOR= #007700]] ==[/COLOR] [COLOR= #DD0000]POST[/COLOR][COLOR= #007700]) {[/COLOR]
[URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/isset"]isset[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]naam[/COLOR][COLOR= #007700]]) && ![/COLOR][URL="http://www.php.net/empty"]empty[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]naam[/COLOR][COLOR= #007700]]) &&[/COLOR] [URL="http://www.php.net/isset"]isset[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]bericht[/COLOR][COLOR= #007700]]) && ![/COLOR][URL="http://www.php.net/empty"]empty[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]bericht[/COLOR][COLOR= #007700]])) {[/COLOR]
[URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/strlen"]strlen[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]naam[/COLOR][COLOR= #007700]]) >[/COLOR] [COLOR= #0000BB]120[/COLOR] [COLOR= #007700]||[/COLOR] [URL="http://www.php.net/strlen"]strlen[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]bericht[/COLOR][COLOR= #007700]]) >[/COLOR] [COLOR= #0000BB]400[/COLOR][COLOR= #007700]) {[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]Je naam of reactie is te lang!<br /><br />[/COLOR][COLOR= #007700];
}[/COLOR][URL="http://www.php.net/else"]else[/URL][COLOR= #007700]{[/COLOR]
[URL="http://www.php.net/setcookie"]setcookie[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"name"[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]naam[/COLOR][COLOR= #007700]],[/COLOR] [URL="http://www.php.net/time"]time[/URL][COLOR= #007700]()+([/COLOR][COLOR= #0000BB]60[/COLOR] [COLOR= #007700]*[/COLOR] [COLOR= #0000BB]60[/COLOR] [COLOR= #007700]*[/COLOR] [COLOR= #0000BB]24[/COLOR] [COLOR= #007700]*[/COLOR] [COLOR= #0000BB]365[/COLOR] [COLOR= #007700]*[/COLOR] [COLOR= #0000BB]1[/COLOR][COLOR= #007700]));[/COLOR]
[URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"INSERT INTO reacties (id, nieuws_id, naam, bericht, datum, ip) VALUES (NULL, "[/COLOR][COLOR= #007700].[/COLOR][URL="http://www.php.net/mysql_real_escape_string"]mysql_real_escape_string[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_GET[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]id[/COLOR][COLOR= #007700]]).[/COLOR][COLOR= #DD0000]", "[/COLOR][COLOR= #007700].[/COLOR][URL="http://www.php.net/mysql_real_escape_string"]mysql_real_escape_string[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]naam[/COLOR][COLOR= #007700]]).[/COLOR][COLOR= #DD0000]", "[/COLOR][COLOR= #007700].[/COLOR][URL="http://www.php.net/mysql_real_escape_string"]mysql_real_escape_string[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]bericht[/COLOR][COLOR= #007700]]).[/COLOR][COLOR= #DD0000]", NOW(), "[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$_SERVER[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]REMOTE_ADDR[/COLOR][COLOR= #007700]].[/COLOR][COLOR= #DD0000]")"[/COLOR][COLOR= #007700]);[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]De reactie is succesvol gepost.<br /><br />[/COLOR][COLOR= #007700];
}
}[/COLOR][URL="http://www.php.net/else"]else[/URL][COLOR= #007700]{[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]Je hebt niet alle velden ingevuld. Je reactie is niet gepost.<br /><br />[/COLOR][COLOR= #007700];
}
}[/COLOR]
?>


Warning: Cannot modify header information - headers already sent by (output started at /home/******/domains/******/public_html/nieuws/config.php:30) in /home/******/domains/******/public_html/nieuws/index.php on line **
0
Thom

Lid

Berichten
10.654
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
We hebben er niet zoveel aan als je niet geeft op welke line het zit
0
Antonn

Lid · Topicstarter

Berichten
8.649
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Thommiee schreef:
We hebben er niet zoveel aan als je niet geeft op welke line het zit
Die begint met setcookie. Sorry maar heb weggehaald aangezien niet klopte want dit is niet me volledige script. Ik kan je wel vertellen dat er boven de setcookie geen echo of tekst staat.
0
Berichten
10.421
Reputatie
4
Punten
0,00
Lid sinds
Laatst gezien
Een witregel anders? Zou zelfs via een include kunnen meeliften. Na de dubbele punt in de foutmelding zou je het betreffende regelnummer moeten zien.
0
Antonn

Lid · Topicstarter

Berichten
8.649
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Aarclay schreef:
Een witregel anders? Zou zelfs via een include kunnen meeliften. Na de dubbele punt in de foutmelding zou je het betreffende regelnummer moeten zien.
Bedenk me opeens dat ik style in config heb geplaatst emo
0
Berichten
4.912
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
slechte maar mogelijke optie is bovenaan ob_start(); neerzetten/
0
Berichten
35.796
Reputatie
1
Punten
0,00
Lid sinds
Laatst gezien
Ja en dat moet je dus ook niet doen.
0
Antonn

Lid · Topicstarter

Berichten
8.649
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Smiegles schreef:
slechte maar mogelijke optie is bovenaan ob_start(); neerzetten/
Ik wist altijd wel dat die slecht was, maar wat doet die eigenlijk?
0

Jouw reactie

Deel je idee, stel een vraag of help een ander verder.

Editor laden…

Praat mee met de One2xs-community.

Inloggen om te reageren