A
Anonymous
Guest
Dear Mr. Moderator
I have 3 codings as follow:
1)form.html---> asking user to LOGIN with username & password. This record stored in mySQL dbase: Login
2)loginsession.php---->to process what are user input in form.html and give a feedback
3)indexsession.php---->execute the page after username & password verified
<? my question is: How can i make a greeting in indexsession.php ,e.g :"welcome username, may involve $username for variable?
--------->
Here are that codings:
loginsession.php
form.html
indexsession.php
THANK YOU[/quote]
I have 3 codings as follow:
1)form.html---> asking user to LOGIN with username & password. This record stored in mySQL dbase: Login
2)loginsession.php---->to process what are user input in form.html and give a feedback
3)indexsession.php---->execute the page after username & password verified
<? my question is: How can i make a greeting in indexsession.php ,e.g :"welcome username, may involve $username for variable?
--------->
Here are that codings:
loginsession.php
Code:
<?php
include("conf.inc.php");
if($HTTP_POST_VARS)
{
$user=check_login($HTTP_POST_VARS["username"],$HTTP_POST_VARS["password"]);
if($user)
{
$SESSION["user"]=$user;
$goto="indexsession.php";
redirect($goto);
exit;
}
else
{
$errmsg="WRONG PASSWORD OR USERNAME";
}
}
include("form.html");
//FUNCTION
function check_login($username,$password)
{
$sql="SELECT * FROM ulogin WHERE username='$username' and password='$password'";
$query=mysql_query($sql);
return mysql_fetch_array($query);
}
?>
Code:
<!doctype html public "-//W3C//DTD HTML 4.0 //EN">
<html>
<head>
<title>Login Page!</title>
</head>
<body bgcolor=#FFGHFF">
<center><?php echo $errmsg;
?></center>
<form method="post" action="loginsession.php">
<table width="50%" border="1" cellspacing="0" cellpadding="0">
<tr>
<td>username</td>
<td>
<input type="text" name="username">
</td>
</tr>
<td>Password</td>
<td>
<input type="password" name="password">
</td>
</tr>
<tr>
<td> </td>
<td>
<input type="submit" name="submit" value="submit">
</td>
</tr>
</table>
</form>
</body>
</html>
Code:
<!doctype html public "-//W3C//DTD HTML 4.0 //EN">
<html>
<head>
<title>Title here!</title>
</head>
<body bgcolor="#FFFFFF">
<?PHP
echo("selamat datang $user");
?>
<table width="50%" border="1" cellspacing="0" cellpadding="0">
<tr>
<td><a href="satu.php">satu.php</a></td>
</tr>
<tr>
<td><a href="dua.php">dua.php</a></td>
</tr>
<tr>
<td><a href="logout.php">logout.php</a></td>
</tr>
</table>
</body>
</html>