0

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 
}
?>

Edited by jboonpradab

3
Contributors
2
Replies
15
Views
3 Years
Discussion Span
Last Post by diafol
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.