Warning (2): Cannot modify header information - headers already sent
by (output started at /home/maheep/domains/phraseout.com/public_html/
cakephp/styleguide/controllers/users_controller.php:71) [CORE/cake/
libs/controller/controller.php, line 615]

when i upload my cakephp project on the server i m getting this
problem
i remove all blank spaces then also  i  m getting this problem please
help me it's very urgent
my controller code is as follows:
<?php
class UsersController extends AppController{
var $name='Users';
var $helpers = array('Html','Form','Javascript','Ajax');
function index(){
$this->User->recursive = 1;
$this->set('users', $this->User->findAll());
}
function login(){
$this->pageTitle ='CMS Home';
$this->layout ='newlayout';
if(!empty($this->data)){
$dbuser = $this->User->findByUsername($this->data['User']
['username']);
if(!empty($dbuser) && ($dbuser['User']['password']==($this->data
['User']['password']))){
$this->Session->write('User', $this->data['User']['username']);
$this->redirect('/entries/index');
}
else{
$this->set('error', 'Either your username or password is incorrect.');
}
}
}
function logout(){
$this->Session->destroy('User');
$this->flash( 'You have been logged out.', '/users/login');
}
function edit($user_id = null){
if (empty($this->data)){
if (!$user_id){
$this->Session->setFlash('Invalid id for Entry');
$this->redirect('/entries/index');
}
$this->data = $this->User->read(null, $user_id);
}
else{
if ($this->User->save($this->data)){
$this->Session->setFlash('The Entry has been saved');
$this->redirect('/entries/index');
}
else{
$this->Session->setFlash('Please correct errors below.');
}
}
}
function add(){
if (empty($this->data)){
$this->render();
}
else{
if ($this->User->save($this->data)){
$this->Session->setFlash('The Entry has been saved');
$this->redirect('/entries/index');
}
else{
$this->Session->setFlash('Please correct errors below.');
}
}
}
function delete($id = null){
if (!$id){
$this->Session->setFlash('Invalid id for User');
$this->redirect('/users/index');
}
if ($this->User->del($id)){
$this->Session->setFlash('Record deleted successfully');
$this->redirect('/users/index');
}
}
}
?>

---------------------------------------Now my view code
--------------------------------------------------------------------

<?php
 if(isset($error)){
 echo "<div class='error'>" . $error . "</div>";
 }
?>
<?php echo $form->create('User',array('action' => 'login'));?>
<fieldset style='background:#eeeeee;'>
<legend ></legend><br/>
<?php echo $form->input('username',array('label' =>'Username
','size'=>'25'));?>
</p>
<p>
<?php echo $form->input('password',array('label' =>'&nbsp;Password
','size'=>'25'));?>
</p>
<?php echo $form->hidden('user/id')?>
<p>
<?php echo $form->submit('Login');?>
</p>
</fieldset>
</form>
<script type='text/javascript'>
document.getElementById('UserUsername').focus();
</script>
---------------------------------------------------now my model
code----------------------------------------------------
<?php
 if(isset($error)){
 echo "<div class='error'>" . $error . "</div>";
 }
?>
<?php echo $form->create('User',array('action' => 'login'));?>
<fieldset style='background:#eeeeee;'>
<legend ></legend><br/>
<?php echo $form->input('username',array('label' =>'Username
','size'=>'25'));?>
</p>
<p>
<?php echo $form->input('password',array('label' =>'&nbsp;Password
','size'=>'25'));?>
</p>
<?php echo $form->hidden('user/id')?>
<p>
<?php echo $form->submit('Login');?>
</p>
</fieldset>
</form>
<script type='text/javascript'>
document.getElementById('UserUsername').focus();
</script>

--------------------------------------Now my entries controller code
to which i m redirecting page ------------
<?php
class EntriesController extends AppController
 {
        var $name = 'Entries';
    var $helpers = array('Html','Form','Javascript','Ajax');
    var $components = array('RequestHandler');
        //var $uses=array('Entry','User');
        function index(){
    $query=mysql_query("select max(counter) from entries");
    $row=mysql_fetch_array($query);
        $co=$row[0];
        $this->set('co',$co);
        $name=$this->Session->read('User');
        $query1=mysql_query("select id from users where username='$name'");
    $row1=mysql_fetch_array($query1);
        $user_id=$row1[0];
        $this->set('user_id',$user_id);
        $this->Entry->recursive = 1;
        $this->set('entries', $this->Entry->findAll(null, null, array
('Section.id' => 'ASC','Submenu.submenu' => 'ASC')));
    }

         function view($id = null){
         if (!$id){
         $this->Session->setFlash('Invalid id for Entry.');
         $this->redirect('/entries/index');
         }
         $this->set('entry', $this->Entry->read(null, $id));
         }

    function add(){
    $this->set('sections', $this->Entry->Section->find('list',array
('fields'=>'Section.section','Section.id')));
        if (empty($this->data)){
        $this->render();
        }
    else{
        $this->data['Entry']['name'] = $this->data['Entry']['File']['name'];
    $this->data['Entry']['type'] = $this->data['Entry']['File']
['type'];
    $this->data['Entry']['size'] = $this->data['Entry']['File']
['size'];
        if ($this->Entry->save($this->data)){
        $id=mysql_insert_id();
        $query=mysql_query("select max(counter) from entries");
    $row=mysql_fetch_array($query);
    $co=$row[0]+1;
    $q=mysql_query("update entries set counter=$co where id=$id");
        $this->Session->setFlash('The Entry has been saved');
        }
    else{
        $this->Session->setFlash('Please correct errors below.');
        $this->redirect('/entries/add');
        }
    if (move_uploaded_file($this->data['Entry']['File']['tmp_name'],
WWW_ROOT.'/files/' .$this->data['Entry']['File']['name']))
    {
        echo "File uploaded successfully";
    }
    else{
    echo "There was an error uploading the file, please try again!";
        }
    $this->redirect('/entries/index');
    }
    }

        function edit($id = null){
        $this->set('sections', $this->Entry->Section->find('list',array
('fields'=>'Section.section','Section.id','recursive' => 1,'page' =>
1,)));
        if (empty($this->data)){
        if (!$id){
        $this->Session->setFlash('Invalid id for Entry');
        $this->redirect('/entries/index');
        }
        $this->data = $this->Entry->read(null, $id);
        }
        else{
    $query=mysql_query("select max(counter) from entries");
    $row=mysql_fetch_array($query);
        $co=$row[0]+1;
    $q=mysql_query("update entries set counter=$co where id=$id");
        if ($this->Entry->save($this->data)){
        $this->Session->setFlash('The Entry has been saved');
        $this->redirect('/entries/index');
        }
        else{
        $this->Session->setFlash('Please correct errors below.');
        }
        }
        }

    function delete($id = null){
        if (!$id){
        $this->Session->setFlash('Invalid id for Entry');
        $this->redirect('/entries/index');
        }
        if ($this->Entry->del($id)){
        $this->Session->setFlash('Record deleted successfully');
        $this->redirect('/entries/index');
        }
        }

    function update_select(){
    if(!empty($this->data['Entry']['section_id'])){
    $section_id = (int)$this->data['Entry']['section_id'];
    $options = $this->Entry->Submenu->find('list',array('section_id'=>
$section_id,'recursive' => 1,'conditions'=>array('section_id'=>
$section_id),'page' => 1,'fields'=>'Submenu.submenu'));
    $this->set('options',$options);
    }
    }
}?>



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to