Results 1 to 4 of 4

Thread: Displaying member name on restricted page

  1. #1
    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.

  2. #2
    Join Date
    Jan 2008
    Posts
    1,521

    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]

  3. #3
    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.

  4. #4
    Join Date
    May 2008
    Posts
    2,012

    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.

Similar Threads

  1. Replies: 10
    Last Post: 03-12-2011, 10:31 AM
  2. displaying web page in a web page
    By sakthi in forum Software Development
    Replies: 1
    Last Post: 05-02-2011, 01:09 AM
  3. Internet Explorer gives Restricted Site Page on opening some sites
    By Heather5 in forum Technology & Internet
    Replies: 5
    Last Post: 21-12-2009, 03:54 PM
  4. MS Word not displaying Page numbers
    By superdave1984 in forum Windows Software
    Replies: 3
    Last Post: 15-10-2009, 03:02 PM
  5. Displaying the column names of a table on a page
    By ricardoramey in forum Software Development
    Replies: 4
    Last Post: 04-08-2008, 01:31 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,714,141,252.19508 seconds with 17 queries