Jump to content

Cannot modify header information


pranshu82202

Recommended Posts

i Have a php code...

 

<?php
session_start();
if(@$_SESSION['ls']!=="loggedin" ) 
{
   header('Location: login.php');    die (" ");
}
if($_GET['via']=="pre_pass")
{
$prepass=$_POST['currentpassword'];
$newpass=$_POST['newpass'];
$renewpass=$_POST['renewpass'];
/*$answer=$_POST['answer'];
&newpassword=$_POST['newpassword'];
*/
if($prepass!=NULL && $newpass!=NULL && $renewpass!=NULL )
{
if(strlen($prepass)==0 || strlen($newpass)==0 || strlen($renewpass)==0)
{
session_start();
$_SESSION['status']="Please fill out all the fields";
header('location:change_password.php?via=previous_password');
die(" ");

}
if(strlen($prepass)<6 || strlen($newpass)<6 || strlen($renewpass)<6)
{
session_start();
$_SESSION['status']="All fields must have atleast 6 characters";
header('location:change_password.php?via=previous_password');
die(" ");

}

if(strcmp($newpass, $renewpass)!=0 && strlen($prepass)>=6 && strlen($newpass)>=6 && strlen($renewpass)>=6 )
{
session_start();
$_SESSION['status']="New password does not match with each other";
header('location:change_password.php?via=previous_password');
die(" ");

}
if(strcmp($prepass, $newpass)==0)
{
session_start();
$_SESSION['status']="New password and Previous Password must be different";
header('location:change_password.php?via=previous_password');
die(" ");

}

mysql_connect ("localhost:3306", "feadmin1","lycosanmamba" ) or die ('Error connecting database'); 
mysql_select_db ("fe_user_info");




$reguserpassword = stripslashes($prepass);
$reguserpassword = mysql_real_escape_string($reguserpassword);
$newpass = stripslashes($newpass);
$newpass = mysql_real_escape_string($newpass);

$sql = "select * from user_info where id='$_SESSION[id]' and password='$reguserpassword'"; 
$res=mysql_query($sql);
$count=mysql_num_rows($res);
if($count=='1')
{
$query= "UPDATE user_info SET password='".$newpass."' WHERE id='$_SESSION[id]'";
mysql_query($query);
session_start();
$_SESSION['status']="Password Successfully Changed";
$_SESSION['mail']="positive";
include("mail/pasword_change_verify_mail.php");

header('location:change_password.php?via=previous_password');
die(" ");

}

if($count!='1')
{
session_start();
$_SESSION['status']="Password you entered does not match with our records";
header('location:change_password.php?via=previous_password');
die(" ");
}
}
}
if($_GET['via']=="sec_ques")
{
$answer=$_POST['answer'];
$newpassword=$_POST['newpassword'];
if($answer!=NULL && $newpassword!=NULL)
{
include('db_connectivity.php');

$sql2 = "select * from user_info where id='$_SESSION[id]' and security_answer='$answer'"; 
$res2=mysql_query($sql2);
$count2=mysql_num_rows($res2);
if(strlen($newpassword)<6)
{
session_start();
$_SESSION['status']="Password must have atleast 6 characters";
header('location:change_password.php?via=security_question');
die(" ");
}
if($count2=='1')
{include('db_connectivity.php');

$newpassword = stripslashes($newpassword);
$newpassword = mysql_real_escape_string($newpassword);
$query= "UPDATE user_info SET password='".$newpassword."' WHERE id='$_SESSION[id]'";
mysql_query($query);
session_start();
$_SESSION['status']="Password Successfully Changed";
$_SESSION['mail']="positive";
include("mail/pasword_change_verify_mail.php");
header('location:change_password.php?via=security_question');
die(" ");

}
else
{
session_start();
$_SESSION['status']="Answer to this security question is incorrect";
header('location:change_password.php?via=security_question');
die(" ");

}

}
}
?>

 

 

but when i run this code it shows me the error..

 

Warning: Cannot modify header information - headers already sent by (output started at C:.................................:2) in C:\...............................\verify_change_password.php on line 118

 

CODE BETWEEN LINE 110-120 is

 

$newpassword = mysql_real_escape_string($newpassword);
$query= "UPDATE user_info SET password='".$newpassword."' WHERE id='$_SESSION[id]'";
mysql_query($query);
session_start();
$_SESSION['status']="Password Successfully Changed";
$_SESSION['mail']="positive";
include("mail/pasword_change_verify_mail.php");
header('location:change_password.php?via=security_question');
die(" ");

}

 

and code of tp 5 line is :

 

<?php
session_start();
if(@$_SESSION['ls']!=="loggedin" ) 
{
   header('Location: login.php');    die (" ");
}

Link to comment
Share on other sites

The problem spot is clearly identified in the error message. It's in whatever that file is, on line 2.

 

Warning: Cannot modify header information - headers already sent by (output started at C:.................................:2) in C:\...............................\verify_change_password.php on line 118

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.