problem with SESSION help me plzzzz


#1

Hi every one I used SESSION in my code to let the user update his file it is a simple code it work but it show me a warning I don’t know why so please help me to solve this problem

form code

[code]<?php
session_start();

if(!isset($_SESSION[‘loggedin’])) {
print’

your not register

register

';
exit(); }
?> body { <?php

// Address error handing.
ini_set (‘display_errors’, 1);
error_reporting (E_ALL & ~E_NOTICE);

// Check for a bg_color value.
if (isset ($_COOKIE[‘bg_color’])) {
print “ttbackground-color: {$_COOKIE[‘bg_color’]};n”;
} else {
print “ttbackground-color: #ffffff;n”;
}

?>
}

update page

<?php if(isset($_SESSION['loggedin'])){ print '

Hi
** ' .$_SESSION['loggedin'] . ' **

'; }?>
<?php $dbc = @mysql_connect ('localhost','root',''); $db_selected = mysql_select_db('recipes_club', $dbc); mysql_query("set charset cp1256"); $result = mysql_query("SELECT * FROM user ", $dbc); $num_rows = mysql_num_rows($result); echo '

'; $name=$_SESSION['loggedin']; $query = "SELECT * FROM user WHERE name ='$name'"; if ($r = mysql_query ($query)) { // Run the query. $row = mysql_fetch_array ($r); // Retrieve the information. // Make the form. print""; print"

"; print"to update your profile {$row['name']}

"; print'


'; print' password

'; print' email
'; print'
countery ' . $row['countery'] .' countery '; print'
'; print'';} else { // Couldn't get the information. print "

Could not retrieve the entry because: " . mysql_error() . ". The query was $query.

"; } print '
'; ?>
[/code]

this is printscreen for it

http://www.arbwb.com/img/download.php?f … c76b9ea781

action code

[code]

<?php session_start(); if(!isset($_SESSION['loggedin'])) { print'

your not register
register

'; exit(); } ?> body { <?php

// Address error handing.
ini_set (‘display_errors’, 1);
error_reporting (E_ALL & ~E_NOTICE);

// Check for a bg_color value.
if (isset ($_COOKIE[‘bg_color’])) {
print “ttbackground-color: {$_COOKIE[‘bg_color’]};n”;
} else {
print “ttbackground-color: #ffffff;n”;
}

?>
}

update page

 

 

<?php if(isset($_SESSION['loggedin'])){ print '

Hi
** ' .$_SESSION['loggedin'] . ' **

'; }?>
<?php $dbc = @mysql_connect ('localhost','root',''); $db_selected = mysql_select_db('recipes_club', $dbc); mysql_query("set charset cp1256"); $name=$_SESSION['loggedin']; $password =$_POST['password']; $email=$_POST['email']; $countery=$_POST['countery']; ini_set ('display_errors', 1); error_reporting (E_ALL & ~E_NOTICE); $name=$_SESSION[loggedin]; if (empty ($password)) { echo ''; } else if (empty ($countery)) { echo ''; } ELSE{ if (is_array ($_POST['countery'])) { foreach ($_POST['countery'] as $c) $query = "UPDATE user SET password='{$_POST['password']}',countery='$c',email='{$_POST['email']}' WHERE name='$name'"; $r = mysql_query ($query); // Execute the query. // Report on the result. if (mysql_affected_rows() == 1) { print '


your profile has been update
'; } else { print "

Could not update the entry because: " . mysql_error() . ". The query was $query.

"; }} else { // Display the entry in a form. // Check for a valid entry ID in the URL. } } mysql_close(); ?>
[/code]

this is printscreen for it

http://www.arbwb.com/img/download.php?f … e6979afe6b

so help me plzzzzzzzzzzzzz :frowning: :(


#2

Have you tried running your warning through google?


#3

Basically the warning means you can have anything above session_start().

This function has to be at the top of the page before anything else sent.

@Zyppora:
Sorry zyppora, Normally I would have just left it at what you wrote, but I must be bored and feeling generous today!


#4

Yea, I didn’t really feel like responding either but someone’s gotta do it heh. Headers get sent by output and session_start() requires those headers.