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
Error with login script
Old 11-08-2009, 04:03 PM Error with login script
Super Talker

Posts: 115
Name: Not Telling
Trades: 0
I am getting an error with my login script:

Error:
Code:
Warning: Cannot modify header information - headers already sent by (output started at /home/bucket/public_html/inc/config.php:7) in /home/bucket/public_html/checklogin.php on line 24
checklogin.php
PHP Code:
<?php
include "inc/config.php";
// username and password sent from form
$myusername=$_POST['myusername'];
$mypassword=$_POST['mypassword'];
// To protect MySQL injection (more detail about MySQL injection)
$myusername stripslashes($myusername);
$mypassword stripslashes($mypassword);
$myusername mysql_real_escape_string($myusername);
$mypassword mysql_real_escape_string($mypassword);
$sql="SELECT * FROM `admin` WHERE username='$myusername' and password='$mypassword'";
$result=mysql_query($sql);
// Mysql_num_row is counting table row
$count=mysql_num_rows($result);
// If result matched $myusername and $mypassword, table row must be 1 row
if($count==1){
// Register $myusername, $mypassword and redirect to file "accounts.php"
session_register("myusername");
session_register("mypassword");
header("location:accounts.php");
}
else 
{
header'Location: accounts-login.php' ) ;
}
?>
Does anyone spot the problem?
__________________
MY MSN:
Please login or register to view this content. Registration is FREE

PHP, HTML, and CSS Coding, Logo and Web Design - Professionally done.
PM me anytime for HTML, PHP or web design help. I will be glad to help you out.
sith717 is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 11-08-2009, 04:12 PM Re: Error with login script
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,517
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
You cannot set sessions or send headers AFTER output is sent to the browser
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 11-08-2009, 05:26 PM Re: Error with login script
lizciz's Avatar
Webmaster Talker

Posts: 744
Name: Mattias Nordahl
Location: Sweden
Trades: 0
That is, make sure there are no echo or print before the header() call, and no new lines or spaces before the opening <?php tag.
__________________
34343639363436653237373432303635373837303635363337 34323037343638363137343263323036343639363432303739 366637353366
lizciz is online now
Reply With Quote
View Public Profile Visit lizciz's homepage!
 
Old 11-08-2009, 06:45 PM Re: Error with login script
tripy's Avatar
Do not try this at home!

Posts: 3,621
Name: Thierry
Location: I'm the uber Spaminator !
Trades: 0
and as stated in the error message, the output has happened in config.php at line 7
Quote:
(output started at /home/bucket/public_html/inc/config.php:7)
__________________
Only a biker knows why a dog sticks his head out the window.
tripy is offline
Reply With Quote
View Public Profile Visit tripy's homepage!
 
Reply     « Reply to Error with login script
 

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.13154 seconds with 12 queries