I had built a register and a login page. When I register and try to login immediately, it works. But if I try it again after restarting my XAMPP, it won't log in. Any suggestions? Here is my login code:
<?php
session_start();
if ($_SESSION["logging"] && $_SESSION["logged"])
{
print_secure_content();
}
else
{
if (!$_SESSION["logging"])
{
$_SESSION["logging"] = true;
loginform();
}
else if ($_SESSION["logging"])
{
$number_of_rows = checkpass();
if ($number_of_rows == 1)
{
$_SESSION[user] = $_GET[userlogin];
$_SESSION[logged] = true;
print "<h1>you have loged in successfully</h1>";
print_secure_content();
}
else
{
print "wrong pawssword or username, please try again";
loginform();
}
}
}
function loginform()
{
print "please enter your login information to proceed with our site";
print("<table border='2'><tr><td>username</td><td><input type='text' name='userlogin' size'20'></td></tr><tr><td>password</td><td><input type='password' name='password' size'20'></td></tr></table>");
print "<input type='submit' >";
print "<h3><a href='registerform.php'>register now!</a></h3>";
}
function checkpass()
{
$servername = "localhost";
$username = "root";
$conn = mysql_connect($servername, $username) or die(mysql_error());
mysql_select_db("konjam_disc", $conn);
$sql = "select * from users where name='$_GET[userlogin]' and password='$_GET[password]'";
$result = mysql_query($sql, $conn) or die(mysql_error());
return mysql_num_rows($result);
}
****** EDIT ******
This is the error that I'm receiving when I go to the login page:
Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /Applications/XAMPP/xamppfiles/htdocs/demo/admin/new/index.php:8) in /Applications/XAMPP/xamppfiles/htdocs/demo/admin/new/index.php on line 9
Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /Applications/XAMPP/xamppfiles/htdocs/demo/admin/new/index.php:8) in /Applications/XAMPP/xamppfiles/htdocs/demo/admin/new/index.php on line 9