pranshu82202 Posted September 3, 2011 Share Posted September 3, 2011 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 (" "); } Quote Link to comment https://forums.phpfreaks.com/topic/246376-cannot-modify-header-information/ Share on other sites More sharing options...
mat3000000 Posted September 3, 2011 Share Posted September 3, 2011 You need to have the php right at the start of the file. Make sure there is no whitespace at all before your <?php tag. If it already is right at the start, download notepad++, copy all your code in there, save. Should sort it. Quote Link to comment https://forums.phpfreaks.com/topic/246376-cannot-modify-header-information/#findComment-1265174 Share on other sites More sharing options...
pranshu82202 Posted September 3, 2011 Author Share Posted September 3, 2011 mat30000 its still their... I copie all my code in notepad++ and then ran it but the error was still their... What to do Quote Link to comment https://forums.phpfreaks.com/topic/246376-cannot-modify-header-information/#findComment-1265179 Share on other sites More sharing options...
Pikachu2000 Posted September 3, 2011 Share Posted September 3, 2011 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 Quote Link to comment https://forums.phpfreaks.com/topic/246376-cannot-modify-header-information/#findComment-1265180 Share on other sites More sharing options...
mat3000000 Posted September 4, 2011 Share Posted September 4, 2011 Sorry, I just don't know. That worked for me. Hope you find the answer though Quote Link to comment https://forums.phpfreaks.com/topic/246376-cannot-modify-header-information/#findComment-1265375 Share on other sites More sharing options...
pranshu82202 Posted September 4, 2011 Author Share Posted September 4, 2011 ya i got the answer, actually the error was in othe included file... Sorr for not marking the topic as solved Thanx for your assistance Quote Link to comment https://forums.phpfreaks.com/topic/246376-cannot-modify-header-information/#findComment-1265377 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.