The problem is, the name getting displayed on screen is the first name of the table How can i tackle it and ensure that the name of the user is derived from his email ID stored in the table. For ex: i first log in as 'a' with email id a@g.com then i log in as 'b' with email id b@g.com now when uer 'b' lands into the welcome page the page displays hello 'a'. So this concludes that the page displays the name of the first user and not the second user. Now, I want it to display b because that is the name to the corresponding email ID b@gmail.com
ANY HELP?
This part loads the table------>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
mysql_select_db($database_register, $register);
$query_getUserDetails = "SELECT `First_name`, `Last_name` FROM register ORDER BY DESC LIMIT 1";
$getUserDetails = mysql_query($query_getUserDetails, $register) or die(mysql_error());
$row_getUserDetails = mysql_fetch_assoc($getUserDetails);
$totalRows_getUserDetails = mysql_num_rows($getUserDetails);
?>
This part get the info from the table----->
<?php echo ' Welcome, ' .$row_getUserDetails['First_name'] . ' ' . $row_getUserDetails['Last_name'] ; ?>
Please stop using the mysql_*
functions - they are deprecated - look at PDO or mysqli
Your problem: You don't have a WHERE
clause in your SQL, meaning that you're always getting the entire set of users from your table. You need something along the lines of
SELECT First_name, Last_name FROM register
WHERE email = '$escaped_email' LIMIT 1
^ This is the important part
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.