PHP login form error messages?

hjfxghd7

New member
Warning: session_register() [function.session-register]: Cannot send session cookie - headers already sent by (output started at /home/friendko/public_html/habitualdarkness/checklogin.php:3) in /home/friendko/public_html/habitualdarkness/checklogin.php on line 37

Warning: session_register() [function.session-register]: Cannot send session cache limiter - headers already sent (output started at /home/friendko/public_html/habitualdarkness/checklogin.php:3) in /home/friendko/public_html/habitualdarkness/checklogin.php on line 37

Warning: Cannot modify header information - headers already sent by (output started at /home/friendko/public_html/habitualdarkness/checklogin.php:3) in /home/friendko/public_html/habitualdarkness/checklogin.php on line 39



This is the code from checklogin.php

<?php include("dbsettings.php"); ?>

<?php
// Connect to server and select database.
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");

// Get values from form

$charName=$_POST['charName'];
$charRace=$_POST['charRace'];
$charClass=$_POST['charClass'];
$charLvl=$_POST['charLvl'];
$prof1=$_POST['charprofession1'];
$prof2=$_POST['charprofession2'];
$email=$_POST['email'];
$password=$_POST['password'];
$pass2=$_POST['password2'];
$md5pass= md5 ('$password');


// To protect MySQL injection (more detail about MySQL injection)
$charName = stripslashes($myusername);
$password = stripslashes($mypassword);
$myusername = mysql_real_escape_string($myusername);
$mypassword = mysql_real_escape_string($mypassword);

$sql="SELECT * FROM $tbl_name WHERE charName='$charName' and password='$password'";
$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("charName");
session_register("password");
header("location:success.php");
}
else {
echo "Wrong Username or Password. Please try again.";
}
?>
 
Back
Top