hi again...
i got another problem using a session..
i need to get the output like
'welcome xxx you are logged in'
using a session i can easily do that by:
echo $_SESSION["username"];
but the problem here i need to join tables to get output of fullname on the screen because I have 2 linked tables as below;
[table login]
userID
username
password
createDate
resetPwd
resetDate
[table user]
userID
title
fullname
email
organisation
status
i wanted to display fullname on the screen, instead of username.
when should i type the command..?
here is my code of login.php..
<?php
/*require 'f:/www/digitallibrary/conf/config.inc.php'; */
require 'f:/www/digitallibrary/conf/smarty.inc.php';
?>
<? $html->display('header.html') ?>
<script language="javascript">
function validate_form(form){
if(form.username.value=="" || form.password.value==""){
alert("Fill out ALL fields.");
return false;
}
return true;
}
</script>
<form name="login" method="post" action="checklogin.php" onsubmit="return validate_form(this)";>
<?
if (isset($_GET['e']) )
{
echo "<font color='red'><b>Wrong Username and Password</b></font>";
}
?>
<?
if (isset($_GET['o']) )
{
echo "<font color='red'><b>You are already logout</b></font>";
}
?>
<table>
<tr>
<td colspan="2"> </td>
</tr>
<tr>
<td colspan="2"> </td>
</tr>
<tr>
<td colspan="2"><b> Login</b></td>
</tr>
<tr>
<td>Username : </td>
<td><input type="text" name="username" id="username" size="15" /></td>
</tr>
<tr>
<td>Password : </td>
<td><input type="password" name="password" id="password" size="15" /></td>
</tr>
<tr>
<td colspan="2"> </td>
</tr>
<tr>
<td colspan="2" align="right"><input type="submit" value="Login" /></td>
</tr>
<tr>
<td colspan="2"> </td>
</tr>
<tr>
<td colspan="2"><h5><a href=forget.php> Forget Password? </a></h5></td>
</tr>
</table>
</form>
<? $html->display('footer.html') ?>
and here the code for processing the form checklogin.php
<?
require 'f:/www/digitallibrary/conf/config.inc.php';
require 'f:/www/digitallibrary/conf/smarty.inc.php';
chdir('../../');
?>
<?
$username = $_POST['username'];
$password = $_POST['password'];
//convert password to md5
//$password = md5($password);
// check if the user info validates the db
$sql="SELECT * FROM dil_logins WHERE username='$username' and password= md5('$password')";
$result=mysql_query($sql);
// Mysql_num_row is counting table row
$count=mysql_num_rows($result);
// If result matched $username and $password, table row must be 1 row
if($count==1){
// Register $username, $password and redirect to file "categories.php"
//session_register("username");
session_start();
$_SESSION['username'] = $username;
echo $next_loc="<script>location.href='../account/user-account.php'</script>";
//session_register("password");
//header("location:categories.php");
//echo "successful login";
}
else {
echo $next_loc="<script>location.href='login.php?e=1'</script>" ;
}
//echo "Wrong Username or Password";
?>
and here where i want it to display 'welcome fullname' ; user-account.php
<?php
chdir('../../');
require_once 'conf/config.inc.php';
require_once 'conf/smarty.inc.php';
//chdir('htdocs/register');
?>
<?php
//session_start();
?>
<?php $html->display('header.html') ?>
<?
//echo "name ".$username;
echo $_SESSION["username"];
?>
<? $html->display('footer.html') ?>
againn... can anybody help me down here..!!