Jump to content

Login


IT-Guy

Recommended Posts

Hey,

 

I have my login, and each user has their own username and password. Once they login, I want it to say, welcome "$firstname" "$lastname"

(Which will be there name). All I really want is their First Name and Last Name to display on the page

ie (Hello, Joe Smith)... So is this how I would do it?

 

<?php
$con = mysql_connect("****","****","****") or die('Could not connect: ' . mysql_error());
mysql_select_db("login", $con);

$result = mysql_query("SELECT * FROM users");
while($row = mysql_fetch_assoc($result)){
  echo "<b>Hello,</b> {$row['firstname']} {$row['lastname']}<br>";

 

Link to comment
Share on other sites

Nope the error Im getting is

 

Parse error: parse error, unexpected $end on line 80

Thats why I was wondering if I was doing it right :(

$con = mysql_connect("****","***","***") or die('Could not connect: ' . mysql_error());
mysql_select_db("login", $con);

$result = mysql_query("SELECT * FROM users");
while($row = mysql_fetch_assoc($result)){
  echo "<b>Hello,</b> {$row['firstname']} {$row['lastname']}<br>";
?>

 

Link to comment
Share on other sites

That should work, I think, test it and let me know.

 

<?php
$con = mysql_connect("****","****","****") or die('Could not connect: ' . mysql_error());
mysql_select_db("login", $con);

$result = mysql_query("SELECT * FROM users");
while($row = mysql_fetch_assoc($result)){
  echo "<b>Hello,</b> {$row['firstname']} {$row['lastname']}<br>";
}
?>

Link to comment
Share on other sites

haha well now the parse error is gone, this is the problem now. Its printing "Hello, $first, $last" (ie: Hello Joe Smith) for every record in the database. I only want it to show the name of the person that corresponds with their login ID. So wouldn't that be a session problem on my login script? Do I need to add a start_session() to the login script? Or is it something that can be fixed just by using my script above?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.