 |
Account Login
|
 |
 |
Latest Articles
|
 |
 |
IRC Channel
|
 |
 |
Associates
|
 |
 |
Associates
|
 |
|
 |
|
 |
|
 |
01-01-2008, 01:55 PM
|
#1 (permalink)
|
|
The Addict
Join Date: Dec 2007
Location: morocco
Posts: 221
Thanks: 19
|
[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 == 1 ) {
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:
Warning: Cannot modify header information - headers already sent by (output started at C:\wamp\www\news\log2.php:1) in 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:1) in C:\wamp\www\news\log2.php on line 11
 so whats the problem !!
Last edited by webtuto : 01-04-2008 at 06:03 PM.
|
|
|
01-01-2008, 02:13 PM
|
#2 (permalink)
|
|
The Frequenter
Join Date: Apr 2005
Location: South UK
Posts: 483
Thanks: 51
|
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
|
|
|
01-01-2008, 02:19 PM
|
#3 (permalink)
|
|
The Addict
Join Date: Dec 2007
Location: morocco
Posts: 221
Thanks: 19
|
Quote:
Originally Posted by Alan @ CIT
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:1) in 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:1) in 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:1) in C:\wamp\www\news\log2.php on line 17
and i think the config.php is fine
|
|
|
01-02-2008, 11:08 AM
|
#4 (permalink)
|
|
The Frequenter
Join Date: Sep 2007
Location: Denmark
Posts: 352
Thanks: 8
|
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
|
|
|
01-02-2008, 11:17 AM
|
#5 (permalink)
|
|
The Addict
Join Date: Dec 2007
Location: morocco
Posts: 221
Thanks: 19
|
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 == 1 ) {
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 error: syntax error, unexpected T_IF in C:\wamp\www\news\log2.php on line 3
|
|
|
01-02-2008, 11:19 AM
|
#6 (permalink)
|
|
The Frequenter
Join Date: Sep 2007
Location: Denmark
Posts: 352
Thanks: 8
|
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
|
|
|
01-02-2008, 11:19 AM
|
#7 (permalink)
|
|
The Frequenter
Join Date: Dec 2007
Location: Bucharest, Romania
Posts: 438
Thanks: 3
|
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.
|
|
|
|
01-02-2008, 11:23 AM
|
#8 (permalink)
|
|
The Addict
Join Date: Dec 2007
Location: morocco
Posts: 221
Thanks: 19
|
Quote:
Originally Posted by xenon
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:
Warning: Wrong parameter count for ob_end_flush() in C:\wamp\www\news\log2.php on line 22
|
|
|
01-02-2008, 11:26 AM
|
#9 (permalink)
|
|
The Addict
Join Date: Dec 2007
Location: morocco
Posts: 221
Thanks: 19
|
Quote:
Originally Posted by Kalle
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
|
|
|
01-02-2008, 11:35 AM
|
#10 (permalink)
|
|
The Frequenter
Join Date: Sep 2007
Location: Denmark
Posts: 352
Thanks: 8
|
Quote:
Originally Posted by webtuto
when i add a column like that =>
ob_start(members) ;
it gaves this error
PHP Code:
Warning: Wrong 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.
|
|
|
01-02-2008, 11:37 AM
|
#11 (permalink)
|
|
The Addict
Join Date: Dec 2007
Location: morocco
Posts: 221
Thanks: 19
|
i didnt gave it any parameter in the first time
just xenon who told me that :d
|
|
|
01-02-2008, 11:38 AM
|
#12 (permalink)
|
|
The Addict
Join Date: Dec 2007
Location: morocco
Posts: 221
Thanks: 19
|
|
|
|
01-03-2008, 11:45 PM
|
#13 (permalink)
|
|
The Addict
Join Date: Dec 2007
Location: morocco
Posts: 221
Thanks: 19
|
up
up
up!!
|
|
|
01-03-2008, 11:59 PM
|
#14 (permalink)
|
|
The Frequenter
Join Date: Nov 2007
Location: Netherlands
Posts: 460
Thanks: 49
|
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"
|
|
|
01-04-2008, 12:11 AM
|
#15 (permalink)
|
|
The Addict
Join Date: Dec 2007
Location: morocco
Posts: 221
Thanks: 19
|
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
|
|
|
01-04-2008, 12:12 AM
|
#16 (permalink)
|
|
The Addict
Join Date: Dec 2007
Location: morocco
Posts: 221
Thanks: 19
|
and im patient lol
|
|
|
01-04-2008, 12:21 AM
|
#17 (permalink)
|
|
Moderateur
Join Date: Apr 2007
Posts: 1,393
Thanks: 5
|
Quote:
Originally Posted by webtuto
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". 
|
|
|
|
01-04-2008, 12:25 AM
|
#18 (permalink)
|
|
The Addict
Join Date: Dec 2007
Location: morocco
Posts: 221
Thanks: 19
|
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:1) in 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:1) in 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:1) in C:\wamp\www\news\log2.php on line 24
that script make me very mad
|
|
|
01-04-2008, 12:33 AM
|
#19 (permalink)
|
|
Moderateur
Join Date: Apr 2007
Posts: 1,393
Thanks: 5
|
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.
|
|
|
|
01-04-2008, 12:35 AM
|
#20 (permalink)
|
|
The Addict
Join Date: Dec 2007
Location: morocco
Posts: 221
Thanks: 19
|
thanks buti tried it and the same problem
|
|
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|