Hi, I am having some trouble with my login PHP script.
My Code is below ( Please let me know if you see any errors with it ) Thanks!
<?php
session_start();
require("db.php");
if(isset($_SESSION['SESS_LOGGEDIN']) == TRUE)
{
header("Location: " . $config_basedir);
}
if(isset($_POST['submit']))
{
//Check to see if they are already logged in on other computer or broswer ( This part is for me to know who is online
$logincheck = mysql_query("SELECT * FROM database.table NATURAL JOIN table2 WHERE username = '". $_POST['username'] . "' AND column = column.id");
$loginfetch = mysql_fetch_assoc($logincheck);
$loginnumrows = mysql_num_rows($logincheck);
if($loginnumrows == 1)
{
$idnum = $loginfetch['id'];
//Delete the last login and renew a new login online
mysql_query("DELETE FROM table WHERE column = " . $idnum);
}
$loginsql = "SELECT * FROM database.table WHERE username = '" . $_POST['username'] . "' AND password = '" . $_POST['password'] . "'";
$loginres = mysql_query($loginsql) or die (mysql_error());
$numrows = mysql_num_rows($loginres);
if($numrows == 1)
{
$loginrow = mysql_fetch_assoc($loginres);
session_register("SESS_LOGGEDIN");
session_register("SESS_USERNAME");
session_register("SESS_USERID");
session_register("SESS_FNAME");
session_register("SESS_LNAME");
$_SESSION['SESS_LOGGEDIN'] = 1;
$_SESSION['SESS_USERNAME'] = $loginrow['username'];
$_SESSION['SESS_USERID'] = $loginrow['id'];
$_SESSION['SESS_FNAME'] = $loginrow['fname'];
$_SESSION['SESS_LNAME'] = $loginrow['lname'];
mysql_query("INSERT INTO table (column_1, column_2) VALUES ('1', '".$loginrow['id']."')");
header("Location:http://www.website.org/home.php");
}
else
{
header("Location:http://www.website.org/login.php?error=1");
}
}
?>
They keep receiving a partial sign in... On the home.php (the place where the user goes once logged) it is showing them an message like "Warning: Mysql_num_rows....." - Then when they refresh or relogin they are taken to their site just fine...
Can someone help me with this matter please?
Also, Im receiving an Error message on my browser saying "Out of Memory on line 12" not sure which script is making it read that. =/