Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 02-09-2009
Members
 
Join Date: May 2009
Posts: 51
Displaying member name on restricted page

I am creating a project in PHP where there are some pages which can be visited by selected members only and if any unrestricted user or member visit that page then his name should get displayed on those restricted pages. I have ask my friends about the same, they told me that it's being possible but don't know about the coding. Can anyone help me out with this issue.
Reply With Quote
  #2  
Old 02-09-2009
Member
 
Join Date: Jan 2008
Posts: 1,515
Displaying member name on restricted page

Yes if you want you can display member name on restricted page for that you need to use the following coding.


PHP Code:
[code=php]
<?php
session_start
();
include(
"cn.php");
$msg "";

if (isset(
$_POST['Submit']))
{

$username $_POST['pfno'];
$password $_POST['ledgerno'];

$result mysql_query("Select * From user_table where pfno='$pfno'",$link);


{

if(
$ledgerno == $row["ledgerno"])
{

$_SESSION['adminok'] = "ok";
$_SESSION['pfno'] = "pfno";
$_SESSION['ledgerno'] = "ledgerno";
$_SESSION['valid_time']=time();
header("Location: Members_Area.php?pfno=".$_SESSION['pfno']);

}
else
{
$msg "ledgerno incorrect";
}
}

{
$msg "pfno incorrect";
}

}
?>

<html >
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Login</title>
</head>

<body>

<table width="200" border="0" align="center" cellpadding="1" cellspacing="2" bgcolor="blue">
<tr>
<form name="form_1" method="post" action="">
<td>
<table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="blue">
<tr>
<td colspan="3"><strong>Members Login </strong></td>
</tr>
<tr>
<td width="78">PF Number </td>
<td width="6">:</td>
<td width="294"><input name="pfno" type="text" id="pfno"></td>
</tr>
<tr>
<td>Ledger Number</td>
<td>:</td>
<td><input name="ledgerno" type="password" id="ledgerno"></td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td><input type="submit" name="Submit" value="Login"></td>
</tr>
</table>
</td>
</form>[/code]

members_area
[code=php]<?php
session_start
();

if (!
$_SESSION["pfno"])
{

header("Location:Login.php");
}
include(
"cn.php");
?>

<html >
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>LIST OF MEMBERS</title>
</head>

<body>
<a href="Members_Area.php">Members Area</a> | <a href="Edit_Profile.php">Edit Profile</a> | <a href="Reports.php">Reports</a> | <a href="Logout.php">Logout</a>
<?php
$pfno
=$_GET["pfno"];
$result=mysql_query("Select * From user_table where pfno='$pfno'") or die (mysql_error());

$user mysql_fetch_assoc($result);
echo 
mysql_num_rows($result);


echo (
"<p>Welcome user" .$user["pfno"]);
echo (
"<p>Logged in: " .date("m/d/Y"$_SESSION["valid_time"]));
?>
</body>
</html>
[/code]
Reply With Quote
  #3  
Old 02-09-2009
Members
 
Join Date: May 2009
Posts: 51
Displaying member name on restricted page

I have try to use the above code on my web page but was not able to display member name on restricted page. Can anyone tell me where Modifier has made any mistake and thanks for replying me. With you code i am able to make some similar type of code.
Reply With Quote
  #4  
Old 02-09-2009
Member
 
Join Date: May 2008
Posts: 2,008
Displaying member name on restricted page

It seems that SQL query which you are using is not proper as the variable pfno is not set before being passed into the query you can have a check over here

PHP Code:
username $_POST['pfno'];
$password $_POST['ledgerno'];

$result mysql_query("Select * From user_table where pfno='$pfno'",$link); 

According to me the SQL query should be as follows

PHP Code:
$result mysql_query("Select * From user_table where pfno='$username'",$link); 
If you want you can store many information in PHP session, if you authenticate the user you can store his name as well in the session too.
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "Displaying member name on restricted page"
Thread Thread Starter Forum Replies Last Post
IE 9 is displaying blank page and showing links as mouse hovered on the page Chitti's Technology & Internet 10 03-12-2011 10:31 AM
displaying web page in a web page sakthi Software Development 1 05-02-2011 01:09 AM
Internet Explorer gives Restricted Site Page on opening some sites Heather5 Technology & Internet 5 21-12-2009 03:54 PM
MS Word not displaying Page numbers superdave1984 Windows Software 3 15-10-2009 03:02 PM
Displaying the column names of a table on a page ricardoramey Software Development 4 04-08-2008 01:31 PM


All times are GMT +5.5. The time now is 05:46 PM.