Hi,
could someone please tell me how to about putting a login name to the homepage of a user when they sign in. for example, after they have logged in using their username and password. Their name would come up in the homepage, like welcome Amy.
This is my checklogin.php if it's any help
<?php
ob_start();
$host="localhost"; // Host name
$username=""; // Mysql username
$password=""; // Mysql password
$db_name="pa"; // Database name
$tbl_name="user"; // Table name
// Get info from the session
// Connect to server and select databse.
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
// Define $myusername and $mypassword and $myusertype
$myusername=$_POST['myusername'];
$mypassword=$_POST['mypassword'];
$myusertype=$_POST['myusertype'];
//$sql="SELECT * FROM $tbl_name WHERE username='$myusername' and //password='$mypassword'";
//$result=mysql_query($sql);
$sql=("SELECT user_type FROM $tbl_name WHERE username='$myusername' and password='$mypassword' and user_type ='$myusertype'");
$result2=mysql_query($sql);
// Mysql_num_row is counting table row
$count=mysql_num_rows($result2);
// If result matched $myusername and $mypassword, table row must be 1 row
if($count==1 ){
//Register $myusername, $mypassword and redirect to file "login_success.php"
session_register("myusername");
session_register("mypassword");
session_register("myusertype");
if($myusertype=="admin"){
header("location:admin/index.php");
}else if($myusertype=="staff"){
echo $result2;
//header("location: tutors/index.php");
}else if($myusertype=="student"){
header("location: students/index.php");
}else{
echo "Wrong usertype";
exit;
}
}
else{
echo "Wrong Username or Password";
}
//ob_end_flush();
?>