
September 22nd, 2003, 11:31 AM
|
|
Junior Member
|
|
Join Date: Sep 2003
Posts: 13
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?
|