Soldato
- Joined
- 24 Nov 2002
- Posts
- 16,378
- Location
- 38.744281°N 104.846806°W
I think I may kill my computer if I can't fix this.
Problem:
Login.php is just a form that's action is checklogin.php.
Contents of checklogin.php:
Contents of login_success.php:
db.php simply contains host, username, pwd and table name for mysql.
I've had similar problems in the past due to whitespaces... but this doesn't appear to be it... anyone got any ideas?
Problem:
Code:
Warning: session_register() [function.session-register]: Cannot send session cookie - headers already sent by (output started at C:\Program Files\xampp\htdocs\HIV\checklogin.php:1) in C:\Program Files\xampp\htdocs\HIV\checklogin.php on line 12
Warning: session_register() [function.session-register]: Cannot send session cache limiter - headers already sent (output started at C:\Program Files\xampp\htdocs\HIV\checklogin.php:1) in C:\Program Files\xampp\htdocs\HIV\checklogin.php on line 12
Warning: Cannot modify header information - headers already sent by (output started at C:\Program Files\xampp\htdocs\HIV\checklogin.php:1) in C:\Program Files\xampp\htdocs\HIV\checklogin.php on line 14
Warning: Unknown: Your script possibly relies on a session side-effect which existed until PHP 4.2.3. Please be advised that the session extension does not consider global variables as a source of data, unless register_globals is enabled. You can disable this functionality and this warning by setting session.bug_compat_42 or session.bug_compat_warn to off, respectively. in Unknown on line 0
Login.php is just a form that's action is checklogin.php.
Contents of checklogin.php:
Code:
<?php
include ("db.php");
$tbl_name="users";
mysql_connect("$host", "$user", "$password")or die("cannot connect");
mysql_select_db("$database")or die("cannot select DB");
$myusername=$_POST['myusername'];
$mypassword=$_POST['mypassword'];
$sql="SELECT * FROM $tbl_name WHERE username='$myusername' and password='$mypassword'";
$result=mysql_query($sql);
$count=mysql_num_rows($result);
if($count==1){
session_register("myusername");
session_register("mypassword");
header("location:login_success.php");
}
else {
echo "Wrong Username or Password";
}
?>
Contents of login_success.php:
Code:
<?
session_start();
if(!session_is_registered(myusername)){
header("location:login.php");
}
?>
<html>
<body>
Login Successful
</body>
</html>
db.php simply contains host, username, pwd and table name for mysql.
I've had similar problems in the past due to whitespaces... but this doesn't appear to be it... anyone got any ideas?