dimanche 19 avril 2015

Warning: Cannot modify header information [duplicate]


This question already has an answer here:




I have read the other posts and tried what they say and im having no luck.


I created the pages on my localhost using IIS and everything works, I have uploaded my pages to a free server and now im getting the error even though what is ment to happen happens (the folders get created, image gets moved and info is stored on mysql) its just not going to the profile page instead its giving me the error message :- Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /srv/disk13/1572246/www/http://ift.tt/1OYcpgk) in /srv/disk13/1572246/www/http://ift.tt/1bgggao on line 22


Warning: Cannot modify header information - headers already sent by (output started at /srv/disk13/1572246/www/http://ift.tt/1OYcpgk) in /srv/disk13/1572246/www/http://ift.tt/1bgggao on line 27


--insert.php --



<?php include("includes/connect.php"); ?>

<?php
include("includes/var.php");

//check if passwords match
if ($password == $cpassword){
//passwords match - check if file is an image
if(substr($imageType,0,5) == "image"){
//check if accounts dir excists
if (is_dir($accounts)){
//check if username account excists
if (is_dir($uploaddir)){
//Yes users directory exists - Move file to $username
if(move_uploaded_file($_FILES['image']['tmp_name'], $uploadfile)) {
//file moves to folder - insert file to MySQL
include("insert_image.php");
}else{
//file does not move
echo "There is a problem with $tmp_name";
}
}else{
mkdir($accounts . $uploaddir , 0777);
mkdir($accounts . $uploaddir . $image_dir, 0777);
mkdir($accounts . $uploaddir . $video_dir, 0777);
include("insert_image.php");
}
}else{
//No account dir exists - create directory
mkdir($accounts , 0777);
mkdir($accounts . $uploaddir , 0777);
mkdir($accounts . $uploaddir . $image_dir, 0777);
mkdir($accounts . $uploaddir . $video_dir, 0777);
include("insert_image.php");
}
}else{
//file is not an image
echo "This is not an image";
}
}else{
//Passwords do not match
echo "Passwords do not match";
}
?>


--insert_image.php--



<?php

move_uploaded_file($_FILES['image']['tmp_name'], $uploadfile);

//add info to the database.
$sql = "INSERT INTO `apply` (`username`,`email`,`password`,`realname`,`location`,`charname`,`class`,`race`,`mainspec`,`rank`,`image_name`,`avatar`)
VALUES ('$username','$email','$password','$realname','$country','$charName','$class','$race','$spec','$rank','$imageName','$imageData')";

if (mysql_query($sql,$con)){
//display the profile
//header ("Location:index.php");
$sql = "SELECT * FROM apply WHERE username='$username'";
$result =mysql_query($sql);
$row = mysql_fetch_assoc($result);
$id = $row['id'];

// Mysql_num_row is counting table row
$count=mysql_num_rows($result);

if ($id){
//if ursername and password is correct get user ID
if($count==1){
session_start();
$_SESSION['loggedin'] = true;
$sql="UPDATE apply SET logged='Yes' WHERE id='$id'" or die ("cant find learner");
$result=mysql_query($sql) or die ("this stuffedup");
//display profile
header ("Location:profile.php?id=$id");
}else{
$_SESSION['loggedin'] = false;
unset($_SESSION['loggedin']);
}
}else{
echo "No ID";
}
}else{
//cant find table
echo 'Cant find table ' . mysql_error();
}
?>

Aucun commentaire:

Enregistrer un commentaire