0

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:

<form action="scripts/loginaction.php" method="POST" name="hoapgform" id="hoapgform"><div style="width: 175px; cursor: default;" onmouseover="return window.status='WEB2: v3.0.95.0';" onmouseout="return window.status='';">                
<input id="OnlineID" name="OnlineID" style="width: 187px;" class="inLoginData" tabindex="1" onfocus="this.select();" onclick="this.select();" onkeydown="loginCK(this,event)" autocomplete="off" type="text">

<div style="padding-top: 6px;"> <div style="float: left;">Password</div></div>

<input id="Password" name="Password" style="width: 187px;" autocomplete="off" maxlength="50" class="inLoginData" onkeydown="loginCK(this,event);" tabindex="2" type="password">
<div style="padding-top: 6px;"> <div style="display: inline;"><input id="RememberOnlineID" tabindex="3" type="checkbox">

Remember Online ID </div><div style="display: inline; padding-top: 2px;"></div>

</div> <label> <input name="login" type="image" id="login" value="Submit" src="images/login.gif" />  </label>     </div>

    <div class="loginItem"><a href="http://www.hoapgar.com/customersupport.php" title="Need Help Logging In?" target="_parent">Need Help Logging In?</a></div>
    <div class="loginItem"><a href="http://www.hoapgar.com/customersupport.php" title="Get Your Login ID" target="_parent">Get Your Login ID</a></div>
    </form>

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']} <br>";
         //ck "Subject : {$row['subject']} <br>" .
         //ck "Message : {$row['message']} <br><br>";
         // "Message : {$row['message']} <br><br>";
}

//ck echo $_SESSION['username'];
?>

Edited by mike_2000_17: Fixed formatting

2
Contributors
1
Reply
2
Views
7 Years
Discussion Span
Last Post by fobos
0

you could try using WHERE statement in your sql syntax..

$query = "SELECT firstname, lastname FROM swilregion132 WHERE onlineid = 'sessionname'" or die("Could not query mysql_query.");

This way its only pulling the information from that specific onlineid.
then u can use the rows for first and last name..
Hope this helps..

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.