Thanks in advance.
Here are the updated files:
login2.php
<?php
session_start();
require_once 'config.php';
# make a variable out of the username that was posted in the index-page.
$username = $_POST['user'];
$escaped_username = mysql_real_escape_string($username);
$password = ($_POST['pass']);
$queryN = mysql_query("select * from userprofile where username ='".$username."' AND password = '".$password."'");
if(mysql_num_rows($queryN) == 1)
{
$resultN = mysql_fetch_assoc($queryN);
$_SESSION['user'] = $_POST['user'];
header("location:login.php");
}
elseif(mysql_num_rows($queryA) == 1)
{
$resultA = mysql_fetch_assoc($queryA);
$_SESSION['admin'] = $_POST['user'];
header("location:login.php");
}
else{
echo "Wrong Username or Password";
}
?>
<form name="back" method="post" action="login.php">
<input type="submit" name="back" id="back" value="Back to Home">
</form>
login.php
<?php
session_start();
require_once 'config.php';
if (isset($_SESSION['user'])){
echo "Welcome ".$_SESSION['user'];
?>
<form name="logout" method="post" action="logout.php">
<input type="submit" name="logout" id="logout" value="Logout">
</form>
<?php
}else{
?>
<head>
<table align="left">
<tr><td>
<form name="login_form" method="post" action="login2.php">
<div id="login-box-name" style="margin-top:10px;">Email:</div><div id="login-box-field" style="margin-top:20px;"><input name="user" id="user" class="form-login" title="Username" value="" size="30" maxlength="2048" /></div>
<div id="login-box-name">Password:</div><div id="login-box-field"><input name="pass" type="password" id="pass" class="form-login" title="Password" value="" size="30" maxlength="2048" /></div>
<span class="login-box-options"><input type="checkbox" name="1" value="1"> Remember Me <a href="#" style="margin-left:10px;">Forgot password?</a></span>
<br />
<br />
<a href="#"><input type="image" name="login" src="/india/images/login-btn.png" width="103" height="42" style="margin-left:90px;" /> </a>
</div>
</div>
</body>
<?php
}
?>
logout.php
<?php
session_start();#This will start the session
session_unset(); #Session_unset and Session_destroy
session_destroy();#Will remove all sessions.
header("location:login.php");#This code will sen du back to the index page
?>
The error is:
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in D:\Hosting\7520570\html\india\login2.php on line 23
but it also says " Wrong Password / User Name and gives the logout button like it is supposed to.