Jump to content

Cannot modify header


robert_gsfame

Recommended Posts

I really confused why was this happened when i was trying to set cookie

 

Page1.php

<?php session_start();?>

<?php require_once('configuration.php');?>

xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

<?php if($_COOKIE["cookies1"]){

$cookies1=$_COOKIE["cookies1"];

$checked1="CHECKED";}

?>

<html>

 

<head>

<body>

<form name="form1" method="post" action="form2.php">

<input type="text" name="text1" value=<?php echo $cookies1>

<input type="checkbox" name="cookies" $checked1>cookies

<input type="submit">

</form>

</body>

</head>

 

then in page2.php

<?php session_start();?>

<?php require_once('configuration.php');?>

xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

<?php $cookies1=$_POST['cookies'];

if(isset($cookies1)){

setcookie("cookies",$_POST['text']);

}?>

 

<html>

 

<head>

<body>

<form name="form1" method="post" action="form2.php">

<input type="text" name="text1" value=<?php echo $cookies1>

<input type="checkbox" name="cookies" $checked1>cookies

<input type="submit">

</form>

</body>

</head>

 

Which part is incorrect as it always give me this result: CANNOT MODIFY HEADER BLABLABLABLABLABLA, and it stated that this part

<?php $cookies1=$_POST['cookies'];

if(isset($cookies1)){

setcookie("cookies",$_POST['text']);

}?>

 

on page2.php seems to be incorrect

 

 

Link to comment
Share on other sites

And since the error message states where the output is occurring at that is preventing the setcookie/header from working, it would take seeing at least the part of the error message that states where that output was started at (i.e. (output started at ....\page2.php:x) where x is the line number) for any one to be able to specifically help you with the problem in your code.

Link to comment
Share on other sites

try eliminating the whitespace at the top of your scripts:

 

<?php
session_start(); //on second line with no whitespace before it;
require_once('configuration.php'); //there's no reason to keep opening and closing php tags for every line of code you write .. keep it fluid;
//continue;
?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.