hi I got a problem with a login script that I could use some help with.
login.php
[php]
Login:
Password:
[/php]
checklogin.php
[php]
Untitled Document
<?php
ob_start();
$host="localhost"; // Host name
$username="xxxxx"; // Mysql username
$password="xxxxx"; // Mysql password
$db_name="xxxxx"; // Database name
$tbl_name="xxxxx"; // Table name
// Connect to server and select databse.
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
// Define $myusername and $mypassword
$myusername=$_POST['login'];
$mypassword=$_POST['pass'];
$sql="SELECT * FROM $tbl_name WHERE login='$myusername' and pass='$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 "login_success.php"
session_register("login");
session_register("pass");
header("location:login_success.php");
}
else {
echo "Wrong Username or Password";
}
ob_end_flush();
?>
[/php]
The error when logging in:
[code]Warning: session_register() [function.session-register]: Cannot send session cookie - headers already sent by (output started at /home/planetzi/public_html/leveling/checklogin.php:11) in /home/planetzi/public_html/leveling/checklogin.php on line 36
Warning: session_register() [function.session-register]: Cannot send session cache limiter - headers already sent (output started at /home/planetzi/public_html/leveling/checklogin.php:11) in /home/planetzi/public_html/leveling/checklogin.php on line 36
Warning: Cannot modify header information - headers already sent by (output started at /home/planetzi/public_html/leveling/checklogin.php:11) in /home/planetzi/public_html/leveling/checklogin.php on line 38[/code]
If you know why I am getting this then please share your knowlege.
Any help is very much aprisiated =)