Evening Sirs!

Well I have a quiet emberrassing problem caused by i don't know what, but I would like to get rid of this issue.

I have a login with session open every .php document. But when I try to open the following file, it stops my session.

This is where the session stops. What could cause the problem? ( init.php included at first line, includes the session_start();)

<?php 
include 'core/init.php';
protect_page();
include 'includes/overall/header.php'; 

$id = $_GET['id'];

if (empty($_POST) === false) {

    $required_fields = array('first_name','last_name','number','district','street', 'house_number', 'appointment_date','anchor','typee');
    foreach($_POST as $key=>$value)

    {
        if (empty($value) && in_array($key, $required_fields) === true)
        {
            $errors[] = 'Fields marked with an asterisk are required';
            break 1;

        }
    }
}       
?>
<center><h1>Meglévő hívás szerkesztése</h1>
<?php
if(isset($_POST['delete']))
{
$sql = "DELETE from sikeres ".
       "WHERE id = $id" ;

$retval = mysql_query( $sql );
if(! $retval )
{
  die('Could not delete data: ' . mysql_error());
}
echo "Hívásodat sikeresen kitöröltük!";
}
else
{

if (isset($_GET['success']) && empty($_GET['success'])) {

echo '<br>Sikeresen frissítettük a hívásodat!';

}
 else {
    if (empty($_POST) === false && empty($errors) === true) {
    $update_data = array(
    'first_name'        => $_POST['first_name'],
    'last_name'         => $_POST['last_name'],
    'number'            => $_POST['number'],
    'district'          => $_POST['district'],
    'street'            => $_POST['street'],
    'house_number'      => $_POST['house_number'],
    'appointment_date'  => $_POST['appointment_date'],
    'appointment_time'  => $_POST['appointment_time'],
    'comment'           => $_POST['comment'],
    'anchor'            => $_POST['anchor'],
    'typee'             => $_POST['typee']
);
update_user($update_data);
header('Location: edit.php?success');


exit();
} else if (empty($errors) === false) {
echo output_errors($errors);
}
$data = mysql_query("SELECT * FROM sikeres where id = $id");
while($info = mysql_fetch_array( $data ))

{
?>
<? if ($info[11] === $user_data['username']) { ?>
<form action="" id="form1" method="post">
    <ul>
        <h2>A tulaj</h2>
        <li>
            Vezetéknév<br>
            <input type="text" value="<?php echo $info['last_name']; ?>" name="first_name">
        </li>
        <li>
            Keresztnév<br>
            <input type="text" value="<?php echo $info['first_name']; ?>" name="last_name">
        </li>
        <li>
            Telefonszám<br>
            <input type="text" value="<?php echo $info['number']; ?>" name="number">
        </li>
        <h2>A lakás</h2>
        <li>
            Kerület<br>
            <input type="text" value="<?php echo $info['district']; ?>" name="district">
        </li>
        <li>
            Utcanév<br>
            <input type="text" value="<?php echo $info['street']; ?>" name="street">
        </li>
        <li>
         Házszám<br>
         <input type="text" value="<?php echo $info['house_number']; ?>" name="house_number">
        </li></ul>
        <h2>A találkozó</h2>
        <ul>
        <li>
        Dátum</br>
        <input type="date" value="<?php echo $info['appointment_date']; ?>" name="appointment_date">

        </li>
        <li>
        Időpont</br>
        <input type="time" value="<?php echo $info['appointment_time']; ?>" name="appointment_time">

        </li>
        <li>
        Megjegyzés</br>
        <input type="text" value="<?php echo $info['comment']; ?>" name="comment"/>
        </li>
        <li>
        Honlap</br>
        <input type="text" value="<?php echo $info['anchor']; ?>" name="anchor"/>

        </li>

<select name="typee">
  <option value="sikeres">Sikeres</option>
  <option value="sikertelen">Sikertelen</option>
</select>
        <li>
        <input type="submit" value="Frissít">
        <input name="delete" type="submit" id="delete" value="Töröl">
        </li>
    </ul>
</form>
<?php
} else { echo 'Sajnáljuk, más tulajdonában lévő hívást nem írhatsz felül!';  }
}
}
} 
include 'includes/overall/footer.php'; ?>

Thanks in advance!

Tibor

This is where the session stops.

What do you mean by that? Do you get any error messages?

init.php included at first line, includes the session_start()

In this case it is important that you post the code of the included file.

On line 61 you have:

header('Location: edit.php?success');

This will not work since you output html before (i.e line 23). Use output buffering or save strings to a variable and output them after line 61.

Where should I set this output buffering? In my init.php where I start the session?

In the above code you can do it just before the inclusion of the files (first line).

Yes I have put ob_start(); at the very first line and I ended it at the very last line. It seems to be working now. Many thanks.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.