Jump to content

plz help me session header error


LOSTBOY

Recommended Posts

hi experts ,

   

        am an php beginner when try to redirect using header() it throws error as below what can i do for this ..

 

Warning: Cannot modify header information - headers already sent by (output started at c:\wamp\www\rapid\user\login.php:3) in c:\wamp\www\rapid\user\login.php on line 9

 

 

my code

<?php
if(isset($_POST['submit'])): ?>
  <?php
    include_once("clsuser.php");

          $objuser = new user;
  $objuser->validateuser($_POST['uname'], $_POST['pass']);
  header('Location: http://localhost/rapid/main/campaign.php');
  ?>
<?php else: ?>

//HTML CODE HERE

Plz help me ASAP

Link to comment
Share on other sites

Your code is using excessive and unnecessary opening and closing php tags. Between the first closing php tag - ?> and the next opening php tag - <?php you have some white-space in your file. This is output to the browser and prevents headers from being sent.

 

When you have a continuous block of php code, put one opening php tag - <?php at the beginning of it and one closing php tag - ?> at the end of it. Don't use three sets of opening and closing php tags like in the posted code.

Link to comment
Share on other sites

When you are using header you can not send an output to the browser because you will get the error which you are getting.

 

So you can't use echo or print. Neither you can send html output. It need's to be clean PHP code, without output and on the end header.

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.