Hi, I'm trying to display the first name of the username using session after they entered username and password. I'm not sure what went wrong with my code. Any suggestion? Thank you.
<?php
//connection string
$con = mysql_connect('127.0.0.1','root')or die(mysql_error());
//select the database
mysql_select_db('local',$con) or die("Unable to connnect!");
//mySQL query
$sql1 ="SELECT username, password, fname FROM tblLogin INNER JOIN tblUser ON tblLogin.email = tblUser.email WHERE username='".$_POST['username']."' AND password='".sha1($_POST['password'])."'";
//check whether the input is valid?
$result= mysql_query($sql1,$con) or die("Error in query:$query.".mysql_error());
if (mysql_num_rows($result) == 1)
{
$row = mysql_fetch_array($result)
$name = $row['fname'];
session_start();
$_SESSION['auth'] = 1;
$_SESSION['firstname']=$name;
header("Location: useraccount.php");
}
else
{
//echo
}
?>