PHP After Login Record display

This is a discussion on "PHP After Login Record display" within the PHP Forum section. This forum, and the thread "PHP After Login Record display are both part of the Program Your Website category.


 Subscribe in a reader

Go Back   Webforumz.com > Main Forums > Program Your Website > PHP Forum

Notices




Reply
 
LinkBack Thread Tools
  #1  
Old Jan 28th, 2008, 18:26
Reputable Member
Join Date: Oct 2007
Location: Liverpool UK
Age: 29
Posts: 220
Thanks: 0
Thanked 0 Times in 0 Posts
PHP After Login Record display

Hello!

I have a php page that is designed as a users profile! When i use the search engine i constructed on my site to search for members i am able to launch the profile with no problems, becuase my search engine lists all members from my database once search has been performed\along with a link to there profile. I recently dicided to include a after login profile using the same profile mentioned above, by starting a PHP sesion. The problem i am having is that unless i use a record update form or a search engine i dont seem to be able to display the logged in users profile data from the database.

Could anyone offer any advice please!!!

All i am looking for is to have the logged in users data to display from the database into my profile page once they log in.

Thanks for any help offered.

I decided to just post all the code in my page to avoid confusion to anyone.

PHP: Select all

<?php require_once('Connections/dbelite.php'); ?><?php
if (!isset($_SESSION)) {
  
session_start();
}
$MM_authorizedUsers "";
$MM_donotCheckaccess "true";
// *** Restrict Access To Page: Grant or deny access to this page
function isAuthorized($strUsers$strGroups$UserName$UserGroup) { 
  
// For security, start by assuming the visitor is NOT authorized. 
  
$isValid False
  
// When a visitor has logged into this site, the Session variable MM_Username set equal to their username. 
  // Therefore, we know that a user is NOT logged in if that Session variable is blank. 
  
if (!empty($UserName)) { 
    
// Besides being logged in, you may restrict access to only certain users based on an ID established when they login. 
    // Parse the strings into arrays. 
    
$arrUsers Explode(","$strUsers); 
    
$arrGroups Explode(","$strGroups); 
    if (
in_array($UserName$arrUsers)) { 
      
$isValid true
    } 
    
// Or, you may restrict access to only certain users based on their username. 
    
if (in_array($UserGroup$arrGroups)) { 
      
$isValid true
    } 
    if ((
$strUsers == "") && true) { 
      
$isValid true
    } 
  } 
  return 
$isValid
}
$MM_restrictGoTo "Login_failed.php";
if (!((isset(
$_SESSION['MM_Username'])) && (isAuthorized("",$MM_authorizedUsers$_SESSION['MM_Username'], $_SESSION['MM_UserGroup'])))) {   
  
$MM_qsChar "?";
  
$MM_referrer $_SERVER['PHP_SELF'];
  if (
strpos($MM_restrictGoTo"?")) $MM_qsChar "&";
  if (isset(
$QUERY_STRING) && strlen($QUERY_STRING) > 0
  
$MM_referrer .= "?" $QUERY_STRING;
  
$MM_restrictGoTo $MM_restrictGoTo$MM_qsChar "accesscheck=" urlencode($MM_referrer);
  
header("Location: "$MM_restrictGoTo); 
  exit;
}
?>
<?php
if (!function_exists("GetSQLValueString")) {
function 
GetSQLValueString($theValue$theType$theDefinedValue ""$theNotDefinedValue ""
{
  
$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;
}
}
$colname_rsWorker "-1";
if (isset(
$_GET['id'])) {
  
$colname_rsWorker $_GET['id'];
}
 

mysql_select_db($database_dbelite$dbelite);
$query_rsWorker sprintf("SELECT tbl_worker.workername, tbl_worker.workersurname, tbl_worker.workergender, tbl_worker.workerage, tbl_worker.workertown, tbl_worker.workeraddress, tbl_worker.workeremail, tbl_worker.workerphone, tbl_worker.workerprogram, tbl_worker.workerabout, tbl_worker.workerjoinreasons, tbl_worker.workerfurtherinfo, tbl_worker.workerphoto FROM tbl_worker WHERE workerid = %s"GetSQLValueString($colname_rsWorker"int"));
$rsWorker mysql_query($query_rsWorker$dbelite) or die(mysql_error());
$row_rsWorker mysql_fetch_assoc($rsWorker);
$totalRows_rsWorker mysql_num_rows($rsWorker);
?>
<!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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Welcome To Your Personal Account</title>
<link href="style/screen.css" rel="stylesheet" type="text/css" />
<style type="text/css">
<!--
.style1 {
 color: #FFFFFF;
 font-weight: bold;
 font-size: 12pt;
}
.style3 {color: #0099FF}
.style4 {
 color: #006600;
 font-weight: bold;
}
.style5 {
 color: #FFFFFF;
 font-weight: bold;
}
-->
</style>
<script src="Scripts/AC_RunActiveContent.js" type="text/javascript"></script>
</head>
<body>
<table width="636" height="681" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td width="636" height="84" valign="top"><div align="center">
      <table width="641" height="26" border="0" cellpadding="0" cellspacing="0">
        <tr>
          <td bgcolor="#99FF33"><div align="center" class="style1">Elite Mail Services | Homeworkers Profile </div></td>
        </tr>
      </table>
      <p>You are now <span class="style3">logged</span> in as: <?php echo $row_rsWorker['workername']; ?> <?php echo $row_rsWorker['workersurname']; ?></p>
    </div>
    <p>&nbsp;</p></td>
  </tr>
  <tr>
    <td valign="top"><table width="640" height="587" border="0" cellpadding="0" cellspacing="0">
      <tr>
        <td width="444" valign="top"><div align="center">
          <table width="406" height="569" border="0" cellpadding="0" cellspacing="0" id="tbl_insert">
            <tr>
              <td width="152" height="45"><div align="left"><span class="style4">Name:</span></div></td>
              <td width="148"><?php echo $row_rsWorker['workername']; ?></td>
            </tr>
            <tr>
              <td height="48"><div align="left"><span class="style4">Surname:</span></div></td>
              <td><?php echo $row_rsWorker['workersurname']; ?></td>
            </tr>
            <tr>
              <td height="41"><div align="left"><span class="style4">Gender:</span></div></td>
              <td><?php echo $row_rsWorker['workergender']; ?></td>
            </tr>
            <tr>
              <td height="46"><div align="left"><span class="style4">Age:</span></div></td>
              <td><?php echo $row_rsWorker['workerage']; ?></td>
            </tr>
            <tr>
              <td height="43"><div align="left"><span class="style4">City:</span></div></td>
              <td><?php echo $row_rsWorker['workertown']; ?></td>
            </tr>
            <tr>
              <td height="44"><div align="left"><span class="style4">I am a member of:</span></div></td>
              <td><?php echo $row_rsWorker['workerprogram']; ?></td>
            </tr>
            <tr>
              <td height="91"><div align="left"><span class="style4">About me:</span></div></td>
              <td><?php echo $row_rsWorker['workerabout']; ?></td>
            </tr>
            <tr>
              <td height="101"><div align="left"><span class="style4">Why i joined:</span></div></td>
              <td><?php echo $row_rsWorker['workerjoinreasons']; ?></td>
            </tr>
            <tr>
              <td><div align="left"><span class="style4">Extra information:</span></div></td>
              <td><?php echo $row_rsWorker['workerfurtherinfo']; ?></td>
            </tr>
          </table>
        </div></td>
        <td width="196" valign="top"><table width="197" height="397" border="0" cellpadding="0" cellspacing="0">
          <tr>
            <td height="194"><img src="uploads/<?php echo $row_rsWorker['workerphoto']; ?> " width="199" height="200" style:"width:300px; max-width:300px" alt="<?php echo $row_rsWorker['workername']; ?> <?php echo $row_rsWorker['workersurname']; ?>" /></td>
          </tr>
          <tr>
            <td valign="top"><table width="198" height="169" border="0" cellpadding="0" cellspacing="0">
              <tr>
                <td><div align="center">
                  <table width="185" height="157" border="2" cellpadding="0" cellspacing="0" bordercolor="#99FF33">
                    <tr>
                      <td height="22" bgcolor="#99FF33"><div align="center"><span class="style5">User control panel</span></div></td>
                    </tr>
                    <tr>
                      <td valign="top"><table width="185" height="135" border="0" cellpadding="0" cellspacing="0">
                        <tr>
                          <td width="141"><div align="right">Edit Profile:</div></td>
                          <td width="44"><div align="center">
                            <script type="text/javascript">
AC_FL_RunContent( 'codebase','http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0','width','38','height','22','src','button3','quality','high','pluginspage','http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash','bgcolor','#FFFFFF','movie','button3' ); //end AC code
</script><noscript><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" width="38" height="22">
                              <param name="movie" value="button3.swf" />
                              <param name="quality" value="high" />
                              <param name="bgcolor" value="#FFFFFF" />
                              <embed src="button3.swf" quality="high" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="38" height="22" bgcolor="#FFFFFF"></embed>
                            </object>
                          </noscript></div></td>
                        </tr>
                        <tr>
                          <td><div align="right">View Account Balance:</div></td>
                          <td><div align="center">
                            <script type="text/javascript">
AC_FL_RunContent( 'codebase','http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0','width','38','height','22','src','button4','quality','high','pluginspage','http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash','bgcolor','#FFFFFF','movie','button4' ); //end AC code
</script><noscript><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" width="38" height="22">
                              <param name="movie" value="button4.swf" />
                              <param name="quality" value="high" />
                              <param name="bgcolor" value="#FFFFFF" />
                              <embed src="button4.swf" quality="high" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="38" height="22" bgcolor="#FFFFFF"></embed>
                            </object>
                          </noscript></div></td>
                        </tr>
                        <tr>
                          <td><div align="right">Contact Support:</div></td>
                          <td><div align="center">
                            <script type="text/javascript">
AC_FL_RunContent( 'codebase','http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0','width','38','height','22','src','button5','quality','high','pluginspage','http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash','bgcolor','#FFFFFF','movie','button5' ); //end AC code
</script><noscript><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" width="38" height="22">
                              <param name="movie" value="button5.swf" />
                              <param name="quality" value="high" />
                              <param name="bgcolor" value="#FFFFFF" />
                              <embed src="button5.swf" quality="high" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="38" height="22" bgcolor="#FFFFFF"></embed>
                            </object>
                          </noscript></div></td>
                        </tr>
                        <tr>
                          <td><div align="right">Delete Account:</div></td>
                          <td><div align="center">
                            <script type="text/javascript">
AC_FL_RunContent( 'codebase','http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0','width','38','height','22','src','button6','quality','high','pluginspage','http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash','bgcolor','#FFFFFF','movie','button6' ); //end AC code
</script><noscript><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" width="38" height="22">
                              <param name="movie" value="button6.swf" />
                              <param name="quality" value="high" />
                              <param name="bgcolor" value="#FFFFFF" />
                              <embed src="button6.swf" quality="high" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="38" height="22" bgcolor="#FFFFFF"></embed>
                            </object>
                          </noscript></div></td>
                        </tr>
                      </table></td>
                    </tr>
                  </table>
                </div></td>
              </tr>
            </table></td>
          </tr>
        </table></td>
      </tr>
    </table></td>
  </tr>
</table>
<table width="636" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td bgcolor="#99FF33"><div align="center"></div></td>
  </tr>
</table>
<p align="center">&nbsp;</p>
<p>&nbsp;</p>
</body>
</html>
<?php
mysql_free_result
($rsWorker);
?>
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote

  #2  
Old Jan 29th, 2008, 09:09
Reputable Member
Join Date: Feb 2006
Location: London
Age: 26
Posts: 103
Thanks: 0
Thanked 1 Time in 1 Post
Re: PHP After Login Record display

When they log in you would be checking their details against details in the database right?

So if they logged in.. you could save their id in a session

$_SESSION['id'] = (value from database)

then, when they go to their profile page, you can run a query like this:

$query_rsWorker ='SELECT tbl_worker.workername, tbl_worker.workersurname, tbl_worker.workergender, tbl_worker.workerage, tbl_worker.workertown, tbl_worker.workeraddress, tbl_worker.workeremail, tbl_worker.workerphone, tbl_worker.workerprogram, tbl_worker.workerabout, tbl_worker.workerjoinreasons, tbl_worker.workerfurtherinfo, tbl_worker.workerphoto FROM tbl_worker WHERE workerid = '.$SESSION['id'];

Does that help?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #3  
Old Jan 29th, 2008, 11:11
Reputable Member
Join Date: Oct 2007
Location: Liverpool UK
Age: 29
Posts: 220
Thanks: 0
Thanked 0 Times in 0 Posts
Re: PHP After Login Record display

Hello Jimz!! Thanks for replying. i was starting to wonder if anyone was still using web forumz!!

Couple of questions if your still here mate.

Question 1:

Do i put this part of the code $_SESSION['id'] = (value from database) in the login page or my profile page???

.................................................. ....................................

Question 2:

In this part of the code = (value from database) do i put a value from the database, like for instance workerloginname ???

.................................................. ....................................

Question 3:

If i use the code exmaple you have given me for starting the session: $_SESSION['id'] = (value from database) do i just this code to the left or do i have to add this to it:

if (!isset($_SESSION)) {
session_start();
}

if (isset($_SESSION['MM_Username'])) {
$username = $_SESSION['MM_Username'];
}


Cheers mate!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #4  
Old Jan 29th, 2008, 12:17
masonbarge's Avatar
Highly Reputable Member
Join Date: Jan 2006
Location: Atlanta GA
Posts: 631
Thanks: 0
Thanked 0 Times in 0 Posts
Re: PHP After Login Record display

longstand - I think the reason you didn't get more response is that the question is a bit overwhelming.

I can add a couple of pointers. First, jimz certainly had a great idea. I will say that I've had more luck avoiding bugs by setting globals to regular variables before using them in queries, etc. Like set "$sessid=$_SESSION['id']" and then use "WHERE workerid='$sessid'" in the query.

You can also, if you want to, set variable inside the $_SESSION array. Like after you start the session, you could set "$_SESSION['age']=" the user's age.

My question is, why don't you just set a cookie in the first place so they don't have to login everytime?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] display a image record from a database with a set size longstand PHP Forum 8 Oct 19th, 2007 19:18
display first only part of a database record. Daddyohhh99 Other Programming Languages 0 Feb 3rd, 2006 14:49
insert record accessman Databases 1 Oct 15th, 2005 01:12
Having two record sets simontheu Classic ASP 7 Oct 22nd, 2004 06:14
display the number of record exist in the database Monie Databases 1 Aug 24th, 2004 08:10


All times are GMT. The time now is 16:19.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42