General Programming Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingGeneral Programming Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old September 22nd, 2003, 11:31 AM
compman compman is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Posts: 13 compman User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
A Login Script Problem

Hello everyone,

Ok, well I'm developing a Content Management System (CMS) for my websites and I'm having some problems with the user validation... what happens is the login form sends the info to this file (aalogin.php) and then what is supposed to happen it it'll check the user data. If it's valid it'll send the cookies to the user and redirect them to the Main Panel using the Location header, if not it'll just display a generic error message. However, I get a bunch of crazy error messages...

Quote:
Warning: Cannot modify header information - headers already sent by (output started at /home/compman/public_html/havoc/admin/aalogin.php:23) in /home/compman/public_html/havoc/admin/aalogin.php on line 35

Warning: Cannot modify header information - headers already sent by (output started at /home/compman/public_html/havoc/admin/aalogin.php:23) in /home/compman/public_html/havoc/admin/aalogin.php on line 36

Warning: Cannot modify header information - headers already sent by (output started at /home/compman/public_html/havoc/admin/aalogin.php:23) in /home/compman/public_html/havoc/admin/aalogin.php on line 37


Here is the code:

PHP Code:
<?
#TekCMS AdminAccess Login Script
#aalogin.php Version 1.0

#Ok, let's get our includes...
include 'aaconfig.php';

#Now we connect to the database..
$sql_link mysql_connect($sql_server$sql_username$sql_password);

if(!
mysql_select_db($sql_dbname$sql_link)) {
 echo(
mysql_error($sql_link));
}

#Let's get the variables from the login form and get them ready for processing...
$uname $_POST['username'];
$pword $_POST['password'];
$pword md5($pword);

#Aright! Now we see if we can validate the user...
$sql_res mysql_query("SELECT * FROM users WHERE username='$uname';");

if(
mysql_num_rows($sql_res) == 0) {
 echo(
'<B>TekCMS: Invalid Username/Password</B>');
}

#if the user exists, then let's check the password...
$row mysql_fetch_array($sql_res);
if(
$row[2] != $pword) {
 echo(
'<B>TekCMS: Invalid Username/Password</B>');
}

#if everything is correct then set the cookies and get the heck outa here!
 
setcookie'aauname'$uname);
 
setcookie'aapword'$pword);
 
header("Location: /index.php");
 
mysql_close($sql_link);
?>


Can anyone help?

Reply With Quote
  #2  
Old September 22nd, 2003, 12:54 PM
dhouston's Avatar
dhouston dhouston is offline
Contributing User
Dev Articles Beginner (1000 - 1499 posts)
 
Join Date: May 2003
Location: Tennessee
Posts: 1,355 dhouston User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Send a message via ICQ to dhouston
You're trying to send multiple headers in a way that PHP doesn't like. Try this with output buffering by adding "ob_start()" at the top of your document and (I think) "ob_flush()" at the end. This'll make sure all your headers are sent at one time and should circumvent this problem.

Reply With Quote
  #3  
Old September 22nd, 2003, 02:40 PM
compman compman is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Posts: 13 compman User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Thanks a lot.

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingGeneral Programming Help > A Login Script Problem


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway
Stay green...Green IT