TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 01-01-2008, 01:55 PM   #1 (permalink)
The Addict
 
webtuto's Avatar
 
Join Date: Dec 2007
Location: morocco
Posts: 221
Thanks: 19
webtuto is on a distinguished road
Plugin/Addon [Solved] Cookies douesnt register why why !!!!!

hi

MY SCRIPT STAND ON THIS
FOR NOW I DONT CARE ABOUT SECURITY THATS WILL COME LATER
here is another problem that i had in my news script

here is the code

PHP Code:
<?php
if (!empty($_POST[name]) and !empty($_POST[pass]) ) {
include(
"config.php") ;
$result mysql_query("select * from members") ;
while (
$row mysql_fetch_array($result) ) {
$id $row[id] ;
}
$query "select user from members where pass='$_POST[pass]'";
$res mysql_query($query) ;
$count mysql_num_rows($res) ;
if (
$count == ) {
 if (!isset(
$_COOKIE[user]) and !isset($_COOKIE[pass]) ) {
   
$timestamp_expire time() + 365*24*3600// Le cookie expirera dans un an
setcookie('user', ($_POST['name']), $timestamp_expire); // On écrit un cookie
setcookie('pass', ($_POST['pass']), $timestamp_expire); // On écrit un autre cookie...
setcookie('id'$id $timestamp_expire); // On écrit un autre cookie...
echo"<meta http-equiv='refresh' content='0;url=user_p.php' ";  
 }else{ echo
"<meta http-equiv='refresh' content='0;url=user_p.php' ";   }
}else{ echo 
"the nickname or password are false try again" ; }
}else{ echo 
"would you please full the forms" ; }
?>
but the cookie douesnt register and it gaves this error
PHP Code:
WarningCannot modify header information headers already sent by (output started at C:\wamp\www\news\log2.php:1in C:\wamp\www\news\log2.php on line 10

Warning
Cannot modify header information headers already sent by (output started at C:\wamp\www\news\log2.php:1in C:\wamp\www\news\log2.php on line 11 
so whats the problem !!

Last edited by webtuto : 01-04-2008 at 06:03 PM.
Send a message via MSN to webtuto Send a message via Yahoo to webtuto Send a message via Skype™ to webtuto
webtuto is offline  
Reply With Quote
Old 01-01-2008, 02:13 PM   #2 (permalink)
Alan @ CIT
Member of the Month
The Frequenter
Member of the Month Top Contributor 
 
Alan @ CIT's Avatar
 
Join Date: Apr 2005
Location: South UK
Posts: 483
Thanks: 51
Alan @ CIT is on a distinguished road
Default

Hi,

This message means that your script has already output something before the cookie information is sent.

Often this is caused by a notice/warning that PHP is sending. Try putting:

PHP Code:
error_reporting(E_ALL); 
as the very first line of your script and see if PHP then shows the errors.

Also, check that config.php isn't sending any output (even a blank space/line) and make sure that "display_errors" is set to true in your php.ini (if you have access to it)

Alan
Send a message via MSN to Alan @ CIT
Alan @ CIT is offline  
Reply With Quote
Old 01-01-2008, 02:19 PM   #3 (permalink)
The Addict
 
webtuto's Avatar
 
Join Date: Dec 2007
Location: morocco
Posts: 221
Thanks: 19
webtuto is on a distinguished road
Default

Quote:
Originally Posted by Alan @ CIT View Post
Hi,

This message means that your script has already output something before the cookie information is sent.

Often this is caused by a notice/warning that PHP is sending. Try putting:

PHP Code:
error_reporting(E_ALL); 
as the very first line of your script and see if PHP then shows the errors.

Also, check that config.php isn't sending any output (even a blank space/line) and make sure that "display_errors" is set to true in your php.ini (if you have access to it)

Alan
here is the error when i added error_reporting(E_ALL)

PHP Code:
Notice: Use of undefined constant id assumed 'id' in C:\wamp\www\news\log2.php on line 7

Notice
: Use of undefined constant user assumed 'user' in C:\wamp\www\news\log2.php on line 13

Notice
: Use of undefined constant pass assumed 'pass' in C:\wamp\www\news\log2.php on line 13

Warning
Cannot modify header information headers already sent by (output started at C:\wamp\www\news\log2.php:1in C:\wamp\www\news\log2.php on line 15

Warning
Cannot modify header information headers already sent by (output started at C:\wamp\www\news\log2.php:1in C:\wamp\www\news\log2.php on line 16

Warning
Cannot modify header information headers already sent by (output started at C:\wamp\www\news\log2.php:1in C:\wamp\www\news\log2.php on line 17 
and i think the config.php is fine
Send a message via MSN to webtuto Send a message via Yahoo to webtuto Send a message via Skype™ to webtuto
webtuto is offline  
Reply With Quote
Old 01-02-2008, 11:08 AM   #4 (permalink)
The Frequenter
Zend Certified 
 
Join Date: Sep 2007
Location: Denmark
Posts: 352
Thanks: 8
Kalle is on a distinguished road
Default

You can fix the constant notices by altering the $_POST references to $_POST['user'], $_POST['pass'] and so on.

The cannot modify header information is caused that you printed something out before sending an HTTP header. This can be fixed by either removing all output being printed above that code. (Tip from experince i sometimes came to add an extra space or newline after my ending ?> which caused these warnings). Or you can use output buffering functions to fix this.

To fix this using output buffering, then add ob_start() to the very start of you script, and ob_end_flush() to the very end and it should work alright.

Hope this helps,
Kalle
Send a message via MSN to Kalle Send a message via Skype™ to Kalle
Kalle is offline  
Reply With Quote
Old 01-02-2008, 11:17 AM   #5 (permalink)
The Addict
 
webtuto's Avatar
 
Join Date: Dec 2007
Location: morocco
Posts: 221
Thanks: 19
webtuto is on a distinguished road
Default

PHP Code:
<?php
ob_start
()
if (!empty(
$_POST[name]) and !empty($_POST[pass]) ) {
error_reporting(E_ALL);  
include(
"config.php") ;
$result mysql_query("select * from members") ;
while (
$row mysql_fetch_array($result) ) {
$id $row[id] ;
}
$query "select user from members where pass='$_POST[pass]'";
$res mysql_query($query) ;
$count mysql_num_rows($res) ;
if (
$count == ) {
 if (!isset(
$_COOKIE[user]) and !isset($_COOKIE[pass]) ) {
   
$timestamp_expire time() + 365*24*3600// Le cookie expirera dans un an
setcookie('user', ($_POST['name']), $timestamp_expire); // On écrit un cookie
setcookie('pass', ($_POST['pass']), $timestamp_expire); // On écrit un autre cookie...
setcookie('id'$id $timestamp_expire); // On écrit un autre cookie...
echo"<meta http-equiv='refresh' content='0;url=user_p.php' ";  
 }else{ echo
"<meta http-equiv='refresh' content='0;url=user_p.php' ";   }
}else{ echo 
"the nickname or password are false try again" ; }
}else{ echo 
"would you please full the forms" ; }
ob_end_flush()
?>
the script become like that right
but it gaves error
PHP Code:
Parse errorsyntax errorunexpected T_IF in C:\wamp\www\news\log2.php on line 3 
Send a message via MSN to webtuto Send a message via Yahoo to webtuto Send a message via Skype™ to webtuto
webtuto is offline  
Reply With Quote
Old 01-02-2008, 11:19 AM   #6 (permalink)
The Frequenter
Zend Certified 
 
Join Date: Sep 2007
Location: Denmark
Posts: 352
Thanks: 8
Kalle is on a distinguished road
Default

You forgot the ending ; after ob_start() and ob_end_flush() function calls =)

ob_start();
ob_end_flush();

Sorry that I wasn't very clear with that, Just thought you added them yourself =P
Send a message via MSN to Kalle Send a message via Skype™ to Kalle
Kalle is offline  
Reply With Quote
Old 01-02-2008, 11:19 AM   #7 (permalink)
The Frequenter
Newcomer 
 
xenon's Avatar
 
Join Date: Dec 2007
Location: Bucharest, Romania
Posts: 438
Thanks: 3
xenon is on a distinguished road
Default

You don't have a column after ob_start, and neither do you after ob_end_flush. Correct that and it should work fine.
__________________
I have optimistic thoughts, even though sometimes (if not always) life's a bitch.
xenon is offline  
Reply With Quote
Old 01-02-2008, 11:23 AM   #8 (permalink)
The Addict
 
webtuto's Avatar
 
Join Date: Dec 2007
Location: morocco
Posts: 221
Thanks: 19
webtuto is on a distinguished road
Default

Quote:
Originally Posted by xenon View Post
You don't have a column after ob_start, and neither do you after ob_end_flush. Correct that and it should work fine.
when i add a column like that =>
ob_start(members) ;

it gaves this error

PHP Code:
WarningWrong parameter count for ob_end_flush() in C:\wamp\www\news\log2.php on line 22 
Send a message via MSN to webtuto Send a message via Yahoo to webtuto Send a message via Skype™ to webtuto
webtuto is offline  
Reply With Quote
Old 01-02-2008, 11:26 AM   #9 (permalink)
The Addict
 
webtuto's Avatar
 
Join Date: Dec 2007
Location: morocco
Posts: 221
Thanks: 19
webtuto is on a distinguished road
Default

Quote:
Originally Posted by Kalle View Post
You forgot the ending ; after ob_start() and ob_end_flush() function calls =)

ob_start();
ob_end_flush();

Sorry that I wasn't very clear with that, Just thought you added them yourself =P
lol sorry i was so happy that it can be the solution so i was in rush i didnt think lol sorry again
but anyway it didnt work here is the script online =>


username = aze password = aze
Send a message via MSN to webtuto Send a message via Yahoo to webtuto Send a message via Skype™ to webtuto
webtuto is offline  
Reply With Quote
Old 01-02-2008, 11:35 AM   #10 (permalink)
The Frequenter
Zend Certified 
 
Join Date: Sep 2007
Location: Denmark
Posts: 352
Thanks: 8
Kalle is on a distinguished road
Default

Quote:
Originally Posted by webtuto View Post
when i add a column like that =>
ob_start(members) ;

it gaves this error

PHP Code:
WarningWrong parameter count for ob_end_flush() in C:\wamp\www\news\log2.php on line 22 
Are you calling ob_start() with a parameter now? Because you shouldn't unless you use an output handler. And you're error is very odd as ob_end_flush() doesn't take any parameters.
Send a message via MSN to Kalle Send a message via Skype™ to Kalle
Kalle is offline  
Reply With Quote
Old 01-02-2008, 11:37 AM   #11 (permalink)
The Addict
 
webtuto's Avatar
 
Join Date: Dec 2007
Location: morocco
Posts: 221
Thanks: 19
webtuto is on a distinguished road
Default

i didnt gave it any parameter in the first time
just xenon who told me that :d
Send a message via MSN to webtuto Send a message via Yahoo to webtuto Send a message via Skype™ to webtuto
webtuto is offline  
Reply With Quote
Old 01-02-2008, 11:38 AM   #12 (permalink)
The Addict
 
webtuto's Avatar
 
Join Date: Dec 2007
Location: morocco
Posts: 221
Thanks: 19
webtuto is on a distinguished road
Default

try this please to see the error

http://81.192.223.238/news/login.php
Send a message via MSN to webtuto Send a message via Yahoo to webtuto Send a message via Skype™ to webtuto
webtuto is offline  
Reply With Quote
Old 01-03-2008, 11:45 PM   #13 (permalink)
The Addict
 
webtuto's Avatar
 
Join Date: Dec 2007
Location: morocco
Posts: 221
Thanks: 19
webtuto is on a distinguished road
Default

up
up
up!!
Send a message via MSN to webtuto Send a message via Yahoo to webtuto Send a message via Skype™ to webtuto
webtuto is offline  
Reply With Quote
Old 01-03-2008, 11:59 PM   #14 (permalink)
The Frequenter
 
ReSpawN's Avatar
 
Join Date: Nov 2007
Location: Netherlands
Posts: 460
Thanks: 49
ReSpawN is on a distinguished road
Default

don't be inpatient...
don't be inpatient...
don't be inpatient!!

First off, your page does NOT open, so I can't help you on that side.

Try this one, and first off, you need to improve your scriptskill because it's a damn mess. Sorry, but at first it was like finding a needle in a haystack ... and no, in_array didn't work.

PHP Code:
<?php
    
    ob_start
();
    
    include(
"config.php") ;
    
error_reporting(E_ALL);  
    
    if ((!empty(
$_POST[name])) && (!empty($_POST[pass]))) {
    
        
$result mysql_query("SELECT * FROM `members`") ;
        
            while (
$row mysql_fetch_array($result)) {
                
$id $row[id] ;
            }
            
        
$query 'SELECT user FROM members WHERE pass = "'.$_POST[pass].'"';
        
$res mysql_query($query) ;
        
$count mysql_num_rows($res) ;
        if (
$count == 1) {
             if ((!isset(
$_COOKIE[user])) && (!isset($_COOKIE[pass]))) {
                   
$timestamp_expire time() + 365*24*3600;
                
setcookie('user'$_POST['name'], $timestamp_expire);
                
setcookie('pass'$_POST['pass'], $timestamp_expire);
                
setcookie('id'$id $timestamp_expire);
                
                echo 
'<meta http-equiv="refresh" content="0;url=user_p.php"';  
             } else {
                echo 
'<meta http-equiv="refresh" content="0;url=user_p.php"';
            }
        } else {
            echo 
"the nickname or password are false try again"
        }
    } else { 
        echo 
"would you please full the forms";
    }
    
    
ob_end_flush();
    
?>
__________________
"Life is a bitch, take that bitch on a ride"
Send a message via MSN to ReSpawN
ReSpawN is offline  
Reply With Quote
Old 01-04-2008, 12:11 AM   #15 (permalink)
The Addict
 
webtuto's Avatar
 
Join Date: Dec 2007
Location: morocco
Posts: 221
Thanks: 19
webtuto is on a distinguished road
Default

respawn about the link it wont work bcz i put wamp offline now
about the mess lol , im a begginer , u have any good suggesions about order
and that code that u gave me
it didnt work
Send a message via MSN to webtuto Send a message via Yahoo to webtuto Send a message via Skype™ to webtuto
webtuto is offline  
Reply With Quote
Old 01-04-2008, 12:12 AM   #16 (permalink)
The Addict
 
webtuto's Avatar
 
Join Date: Dec 2007
Location: morocco
Posts: 221
Thanks: 19
webtuto is on a distinguished road
Default

and im patient lol
Send a message via MSN to webtuto Send a message via Yahoo to webtuto Send a message via Skype™ to webtuto
webtuto is offline  
Reply With Quote
Old 01-04-2008, 12:21 AM   #17 (permalink)
Moderateur
RegEx Guru PHP Guru Top Contributor Advanced Programmer 
 
Salathe's Avatar
 
Join Date: Apr 2007
Posts: 1,393
Thanks: 5
Salathe is on a distinguished road
Default

Quote:
Originally Posted by webtuto View Post
and that code that u gave me
it didnt work
Please, if code does not work for you, give everyone some details. At the very least, copy and paste any error message(s). We can't help if all you give us is "it didnt work".
Salathe is offline  
Reply With Quote
Old 01-04-2008, 12:25 AM   #18 (permalink)
The Addict
 
webtuto's Avatar
 
Join Date: Dec 2007
Location: morocco
Posts: 221
Thanks: 19
webtuto is on a distinguished road
Default

here is the errors =>

PHP Code:
Notice: Use of undefined constant name assumed 'name' in C:\wamp\www\news\log2.php on line 8

Notice
: Use of undefined constant pass assumed 'pass' in C:\wamp\www\news\log2.php on line 8

Notice
: Use of undefined constant id assumed 'id' in C:\wamp\www\news\log2.php on line 13

Notice
: Use of undefined constant id assumed 'id' in C:\wamp\www\news\log2.php on line 13

Notice
: Use of undefined constant id assumed 'id' in C:\wamp\www\news\log2.php on line 13

Notice
: Use of undefined constant pass assumed 'pass' in C:\wamp\www\news\log2.php on line 16

Notice
: Use of undefined constant user assumed 'user' in C:\wamp\www\news\log2.php on line 20

Notice
: Use of undefined constant pass assumed 'pass' in C:\wamp\www\news\log2.php on line 20

Warning
Cannot modify header information headers already sent by (output started at C:\wamp\www\news\log2.php:1in C:\wamp\www\news\log2.php on line 22

Warning
Cannot modify header information headers already sent by (output started at C:\wamp\www\news\log2.php:1in C:\wamp\www\news\log2.php on line 23

Warning
Cannot modify header information headers already sent by (output started at C:\wamp\www\news\log2.php:1in C:\wamp\www\news\log2.php on line 24 
that script make me very mad
Send a message via MSN to webtuto Send a message via Yahoo to webtuto Send a message via Skype™ to webtuto
webtuto is offline  
Reply With Quote
Old 01-04-2008, 12:33 AM   #19 (permalink)
Moderateur
RegEx Guru PHP Guru Top Contributor Advanced Programmer 
 
Salathe's Avatar
 
Join Date: Apr 2007
Posts: 1,393
Thanks: 5
Salathe is on a distinguished road
Default

Please take the time to read through, and act on, all of the information made available to you in this topic. The Notice errors that you're getting have already been identified and a solution given to you earlier in the topic (thanks Kalle). You should not use $_POST[name] unless name is defined as a constant in your script (which is isn't, and you shouldn't!). To access the name item in the $_POST array, you need to use: $_POST['name']. Note the single quotes around name.

The final three Warnings are because PHP sent output to the page already: the Notice errors.
Salathe is offline  
Reply With Quote
Old 01-04-2008, 12:35 AM   #20 (permalink)
The Addict
 
webtuto's Avatar
 
Join Date: Dec 2007
Location: morocco
Posts: 221
Thanks: 19
webtuto is on a distinguished road
Default

thanks buti tried it and the same problem
Send a message via MSN to webtuto Send a message via Yahoo to webtuto Send a message via Skype™ to webtuto
webtuto is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT. The time now is 11:33 PM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design