Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
What is this pls need Help
Old 06-24-2005, 08:55 AM What is this pls need Help
Uche's Avatar
Extreme Talker

Posts: 174
Location: Nigeria/Lagos
Trades: 0
Hello guys Don't really understand what is the meaning of this pls.
Warning: Cannot modify header information - headers already sent by (output started at /home/uchealon/public_html/db.php:6) in /home/uchealon/public_html/loginusers.php on line 8

here is my code.
PHP Code:
<?php
include ("db.php");
$username $_POST['username'];
$password $_POST['password'];

$query mysql_query("SELECT * FROM users WHERE username = '$username' AND password = '$password' ");
while(
$row mysql_fetch_array($query)){
header("location: members.php");

{
echo 
"Username or Password incorrect Please try again";
include 
"error.php";
}
?>
__________________
Life is just lyke a school where everybody goes to learn one or two thing. the more u school, the more u learn more about school..The more we live our lifes.. the more we learn more about life.

Please login or register to view this content. Registration is FREE
Uche is offline
Reply With Quote
View Public Profile Visit Uche's homepage!
 
 
Register now for full access!
Old 06-24-2005, 10:01 AM
amw_drizz's Avatar
Ultra Talker

Posts: 340
Name: Jon
Location: New York
Trades: 0
your trying to send this to the browser after one of your includes has headers in it.

PHP Code:
header("location: members.php"); 
in your db.php if it has anything to deal with headers you will get this error. thats the only reason i can think of that would cause this error.
__________________
AMW_Drizz
Dev Machine:: Apache 2.2.6 PHP 5.2.6 MySQL 5.1
amw_drizz is offline
Reply With Quote
View Public Profile Visit amw_drizz's homepage!
 
Old 06-24-2005, 07:03 PM
metho's Avatar
Ultra Talker

Posts: 481
Location: Gold Coast - Brisbane QLD, Australia
Trades: 0
When a script includes a header redirect, any output to the browser before the header call will stuff it up. In your case, if db.php throws an error notice or die() message, it's outputting to the header thus wrecking the header('Location:').

I also think this script snipped has logic errors. Why on earth would you want a redirect contained in a while loop? As soon as the loop iterates the first time the page will redirect...
__________________
I do
Please login or register to view this content. Registration is FREE
based.
Spend a lot of time in
Please login or register to view this content. Registration is FREE
.
And
Please login or register to view this content. Registration is FREE
chews up the rest.
metho is offline
Reply With Quote
View Public Profile Visit metho's homepage!
 
Old 06-24-2005, 08:30 PM
Junior Talker

Posts: 4
Trades: 0
If you use header(); or setcookie(); you must use the functions ob_start() AND ob_end_flush();
Like this:
PHP Code:
<?php
ob_start
();
require_once(
"db.php");

If(
$_SERVER['REQUEST_METHOD'] == "POST")
{
    
$query mysql_query("SELECT count(1) FROM `users` WHERE username='".$_POST['username']."' AND password='".$_POST['password']."'")or die(mysql_error()); 

    If(
mysql_result($query0))
    {
        
header("location: members.php"); 
    } 
    Else
    { 
        echo 
'Username or Password incorrect Please try again'
    } 
}
Else
{
    
// Your form here..
}

ob_end_flush();
?>
Enrico is offline
Reply With Quote
View Public Profile
 
Old 06-25-2005, 09:16 AM
Uche's Avatar
Extreme Talker

Posts: 174
Location: Nigeria/Lagos
Trades: 0
Thanks guys.. but again i try registring and it went on telling me Registration accepted, yet when i try login in the name and password.. keeps on telling me Username or password incorrect. cos i tried it out by using unexit name and password in the DB. to register it goes on and tells me registration accepted but trying login in with the name. and password it woun't go in..

Even the exiting name and password in the DB, same thing it woun't login either, that was what brought out that error i pasted earlier on.. so what's on boad now is. if any person register, it will go in and not submitting infos. and if at all it does it woun't login you in..

So what might be the problem.

Thanks for your help.
__________________
Life is just lyke a school where everybody goes to learn one or two thing. the more u school, the more u learn more about school..The more we live our lifes.. the more we learn more about life.

Please login or register to view this content. Registration is FREE
Uche is offline
Reply With Quote
View Public Profile Visit Uche's homepage!
 
Reply     « Reply to What is this pls need Help
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

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





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.15268 seconds with 12 queries