Hi friends:
Earlier I was able to fix a login code with your help. Now, I wanted to try if after verifying the login credentials using email and password of session user, I can display the users first name from a database, so in the code that we fixed earlier where I had a page called login.php I tried to make some changes to get the desired result.
The altered and current login.php file code is:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<body>
<?php include("header.php");include("config.php"); ?>
<!-- END HEADER --->
<?php if (isset($_SESSION['user'])){
$result = mysql_query("SELECT 'fname' FROM userprofile
WHERE username=='(isset($_SESSION['user']))'")' or die(mysql_error());
echo "Welcome ".'$result');
?>
<!-- BEGIN FOOTER -->
<?php include("footer.php"); ?>
</body>
</html>
The error I get is:
Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in D:\Hosting\3420630\html\test\login.php on line 14
The original working code is:
<?php
session_start();
require_once 'config.php';
if (isset($_SESSION['user'])){
echo "Welcome ".$_SESSION['user'];
?>
<form name="logout" method="post" action="logout.php">
<input type="submit" name="logout" id="logout" value="Logout">
</form>
<?php
}else{
?>
<table align="left">
<tr><td>
<form name="login_form" method="post" action="login2.php">
<div id="login-box-name" style="margin-top:10px;">Email:</div><div id="login-box-field" style="margin-top:20px;"><input name="user" id="user" class="form-login" title="Username" value="" size="30" maxlength="2048" /></div>
<div id="login-box-name">Password:</div><div id="login-box-field"><input name="pass" type="password" id="pass" class="form-login" title="Password" value="" size="30" maxlength="2048" /></div>
<span class="login-box-options"><input type="checkbox" name="1" value="1"> Remember Me <a href="#" style="margin-left:10px;">Forgot password?</a></span>
<br />
<br />
<a href="#"><input type="image" name="login" src="/india/images/login-btn.png" width="103" height="42" style="margin-left:90px;" /></a>
</div>
</div></form></table>
<?php
}
?>
Can someone please help me see my mistake? Thanks in advance.🙂