LOSTBOY Posted February 1, 2008 Share Posted February 1, 2008 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 Quote Link to comment https://forums.phpfreaks.com/topic/88901-plz-help-me-session-header-error/ Share on other sites More sharing options...
PHP Monkeh Posted February 1, 2008 Share Posted February 1, 2008 http://www.phpfreaks.com/forums/index.php/topic,37442.0.html Could've saved yourself the trouble by reading the sticky Quote Link to comment https://forums.phpfreaks.com/topic/88901-plz-help-me-session-header-error/#findComment-455360 Share on other sites More sharing options...
LOSTBOY Posted February 1, 2008 Author Share Posted February 1, 2008 thanks for reply ya read it that thread but i cant understand ....please suggest me by code example Quote Link to comment https://forums.phpfreaks.com/topic/88901-plz-help-me-session-header-error/#findComment-455371 Share on other sites More sharing options...
PFMaBiSmAd Posted February 1, 2008 Share Posted February 1, 2008 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. Quote Link to comment https://forums.phpfreaks.com/topic/88901-plz-help-me-session-header-error/#findComment-455391 Share on other sites More sharing options...
revraz Posted February 1, 2008 Share Posted February 1, 2008 clsuser.php probably echos something to the browser. Quote Link to comment https://forums.phpfreaks.com/topic/88901-plz-help-me-session-header-error/#findComment-455399 Share on other sites More sharing options...
PFMaBiSmAd Posted February 1, 2008 Share Posted February 1, 2008 Line 3 of the file, where the error message reports the output is occurring, is the indented line with - white-space<?php Quote Link to comment https://forums.phpfreaks.com/topic/88901-plz-help-me-session-header-error/#findComment-455423 Share on other sites More sharing options...
LOSTBOY Posted February 2, 2008 Author Share Posted February 2, 2008 thanks alot for ur suggestions ..let me try Quote Link to comment https://forums.phpfreaks.com/topic/88901-plz-help-me-session-header-error/#findComment-455892 Share on other sites More sharing options...
budimir Posted February 2, 2008 Share Posted February 2, 2008 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. Quote Link to comment https://forums.phpfreaks.com/topic/88901-plz-help-me-session-header-error/#findComment-456049 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.