这段代码中的错误是什么?它总是在其他地方

Why is this code not working?

It always go in else and set $_SESSION['wronglogin']=1; it is a login script which takes input of email-id and password and then checks that if any such thing exists then it should start $_SESSION['loggedin'] otherwise $_SESSION['wronglogin']. I have tried a lot but i am just not getting it

$_SESSION['login-id']=$loginid;
$_SESSION['loginpassword']=$loginpassword;


$loginid = stripslashes($loginid);
$loginpassword = stripslashes($loginpassword);
$loginid = mysql_real_escape_string($loginid);
$loginpassword = mysql_real_escape_string($loginpassword);

$con = mysql_connect("localhost", "moodabsz_naman", "database") or die(mysql_error());
mysql_select_db("moodabsz_database",$con) or die(mysql_error());

$sql="SELECT * 
FROM  user 
WHERE  `email_id` =  '$loginid'
AND  `password` =  '$loginpassword'";
$result=mysql_query($sql);

$count=mysql_num_rows($result);
if($count==1){
    $_SESSION['loggedin']=1;


    mysql_close($con);

    header('location: index.php');

}
else {

    $_SESSION['wronglogin']=1;
    echo "Wrong Username or Password";

    mysql_close($con);

    header('Location: index.php');
}

can you copy the output of this,

<?php
$_SESSION['login-id']=$loginid;
$_SESSION['loginpassword']=$loginpassword;


$loginid = stripslashes($loginid);
$loginpassword = stripslashes($loginpassword);
$loginid = mysql_real_escape_string($loginid);
$loginpassword = mysql_real_escape_string($loginpassword);

$con = mysql_connect("localhost", "moodabsz_naman", "database") or die(mysql_error());
mysql_select_db("moodabsz_database",$con) or die(mysql_error());

$sql="SELECT * 
FROM  `user` 
WHERE  `email_id` =  '$loginid'
AND  `password` =  '$loginpassword'";

$result=mysql_query($sql) or die(mysql_error());

$count=mysql_num_rows($result);

echo 'Debug::Count-'.$count;

if($count==1){
    $_SESSION['loggedin']=1;


    mysql_close($con);

   // header('location: index.php');

}
else {

    $_SESSION['wronglogin']=1;
    echo "Wrong Username or Password";

    mysql_close($con);

    //header('Location: index.php');
}

The above code is not working because missing the session_start() function which should be placed at the first line of your PHP code.

<?php
session_start();
/*

The rest of your code

*/
?>