When a user logs in, the user is directed to a page called accountsummary.php. I have sessions enabled. I can successfully echo the inputed username, and echo the ENTIRE column of firstname and lastname for the entire table. The problem is that I do not want to echo the entire column or firstname and lastname. I only want to echo the firstname and lastname of the user name. Can anyone help with this?
This is the code for the login form on the index page:
Password
Remember Online ID
Need Help Logging In?
Get Your Login ID
this is the loginaction.php:
<?php
session_start( );
include("../scripts/cred.inc");
$OnlineID=$_POST['OnlineID'];
$Password=$_POST['Password'];
if ($OnlineID &&$Password)
{
$connect = mysql_connect($dbServer, $dbUser, $dbPass) or die("Could not connect to mysql server.");
mysql_select_db("$dbDatabase") or die ("The Site down for scheduled maintenance. Please try back later. We are sorry for the inconvenience.");
}
else
header("location:../tryagain.php");
$query = mysql_query("SELECT * FROM swilregion132 WHERE OnlineID='$OnlineID'");
$numrows = mysql_num_rows($query);
if ($numrows !=0)
{
while ($row = mysql_fetch_assoc($query)) // code to log in
{
$dbOnlineID = $row['OnlineID'];
$dbPassword = $row['Password'];
}
if ($OnlineID==$dbOnlineID&&$Password==$dbPassword)
{
//ck echo "You're In!"; //if successfully logged in.
$_SESSION['username']=$OnlineID;
header("location:../accountsummary.php");
}
else
//ck echo "Incorrect Password"; //if failed to logged in.
header("location:../tryagain.php");
}
else
header("location:../tryagain.php");
?>
This is the accountsummary.php:
<?php
session_start( );
$dbServer = "192.168.1.10";
$dbUser = "root";
$dbPass = "password";
$dbDatabase = "hud";
$connect = mysql_connect($dbServer, $dbUser, $dbPass) or die("Could not connect to mysql server.");
mysql_select_db("$dbDatabase") or die ("The Site down for scheduled maintenance. Please try back later. We are sorry for the inconvenience.");
//ck $query = "SELECT firstname, lastname FROM swilregion132" or die("Could not query mysql_query.");
$query = "SELECT firstname, lastname FROM swilregion132" or die("Could not query mysql_query.");
$result = mysql_query($query);
while($row = mysql_fetch_array($result))
{
echo " {$row['firstname']} " .
" {$row['lastname']}
";
//ck "Subject : {$row['subject']}
" .
//ck "Message : {$row['message']}
";
// "Message : {$row['message']}
";
}
//ck echo $_SESSION['username'];
?>