Jump to content

Recommended Posts

I want to display only the row of the db that matches the firstname and lastname stored in the session....

 

right now it is displaying all items on the table....

 

here it is the  code

 

<?php require_once('../Connections/unica.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.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;

}

}

 

$currentPage = $_SERVER["PHP_SELF"];

 

$maxRows_rsclient = 10;

$pageNum_rsclient = 0;

if (isset($_GET['pageNum_rsclient'])) {

  $pageNum_rsclient = $_GET['pageNum_rsclient'];

}

$startRow_rsclient = $pageNum_rsclient * $maxRows_rsclient;

 

mysql_select_db($database_unica, $unica);

$query_rsclient = "SELECT * FROM client_info ORDER BY lastname ASC";

$query_limit_rsclient = sprintf("%s LIMIT %d, %d", $query_rsclient, $startRow_rsclient, $maxRows_rsclient);

$rsclient = mysql_query($query_limit_rsclient, $unica) or die(mysql_error());

$row_rsclient = mysql_fetch_assoc($rsclient);

 

if (isset($_GET['totalRows_rsclient'])) {

  $totalRows_rsclient = $_GET['totalRows_rsclient'];

} else {

  $all_rsclient = mysql_query($query_rsclient);

  $totalRows_rsclient = mysql_num_rows($all_rsclient);

}

$totalPages_rsclient = ceil($totalRows_rsclient/$maxRows_rsclient)-1;

 

$maxRows_rsJob = 10;

$pageNum_rsJob = 0;

if (isset($_GET['pageNum_rsJob'])) {

  $pageNum_rsJob = $_GET['pageNum_rsJob'];

}

$startRow_rsJob = $pageNum_rsJob * $maxRows_rsJob;

 

mysql_select_db($database_unica, $unica);

$query_rsJob = "SELECT * FROM cust_info ORDER BY lastname ASC";

$query_limit_rsJob = sprintf("%s LIMIT %d, %d", $query_rsJob, $startRow_rsJob, $maxRows_rsJob);

$rsJob = mysql_query($query_limit_rsJob, $unica) or die(mysql_error());

$row_rsJob = mysql_fetch_assoc($rsJob);

 

if (isset($_GET['totalRows_rsJob'])) {

  $totalRows_rsJob = $_GET['totalRows_rsJob'];

} else {

  $all_rsJob = mysql_query($query_rsJob);

  $totalRows_rsJob = mysql_num_rows($all_rsJob);

}

$totalPages_rsJob = ceil($totalRows_rsJob/$maxRows_rsJob)-1;

 

$queryString_rsJob = "";

if (!empty($_SERVER['QUERY_STRING'])) {

  $params = explode("&", $_SERVER['QUERY_STRING']);

  $newParams = array();

  foreach ($params as $param) {

    if (stristr($param, "pageNum_rsJob") == false &&

        stristr($param, "totalRows_rsJob") == false) {

      array_push($newParams, $param);

    }

  }

  if (count($newParams) != 0) {

    $queryString_rsJob = "&" . htmlentities(implode("&", $newParams));

  }

}

$queryString_rsJob = sprintf("&totalRows_rsJob=%d%s", $totalRows_rsJob, $queryString_rsJob);

 

$queryString_rsclient = "";

if (!empty($_SERVER['QUERY_STRING'])) {

  $params = explode("&", $_SERVER['QUERY_STRING']);

  $newParams = array();

  foreach ($params as $param) {

    if (stristr($param, "pageNum_rsclient") == false &&

        stristr($param, "totalRows_rsclient") == false) {

      array_push($newParams, $param);

    }

  }

  if (count($newParams) != 0) {

    $queryString_rsclient = "&" . htmlentities(implode("&", $newParams));

  }

}

$queryString_rsclient = sprintf("&totalRows_rsclient=%d%s", $totalRows_rsclient, $queryString_rsclient);

?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"><!-- InstanceBegin template="/Templates/index.dwt" codeOutsideHTMLIsLocked="false" -->

<head>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />

<meta name="description" content="Your description goes here..." />

<meta name="keywords" content="your,keywords,goes,here" />

<meta name="author" content="Your Name / Design by Andreas Viklund - http://andreasviklund.com/" />

<link rel="stylesheet" type="text/css" href="adm/1024px.css" title="1024px style" media="screen,projection" />

<!-- InstanceBeginEditable name="doctitle" -->

<title>Client List</title>

<!-- InstanceEndEditable -->

<!-- InstanceBeginEditable name="head" --><!-- InstanceEndEditable -->

<style type="text/css">

<!--

.style1 {

color: #4088B8;

font-weight: bold;

}

body {

margin-left: 0px;

margin-right: 0px;

}

-->

</style>

</head>

 

<body>

<div id="wrap">

 

<div id="header">

<p> </p>

<table width="971" border="0" cellpadding="0" cellspacing="0">

  <tr>

    <td bgcolor="#E8A50E"><img src="img/Untitled-1.gif" alt="" width="500" height="109" /></td>

  </tr>

  <tr>

    <td height="25"><a href="admin.php">home</a> | <a href="home.php">Admin</a> | <a href="myaccount.php">My Account</a> | <a href="clientmaster.php">Clients</a> | <a href="crewmaster.php">Staff</a> | <a href="logout.php">Logout</a></td>

  </tr>

</table>

<p> </p>

</div>

 

<!-- InstanceBeginEditable name="body" -->

<div id="contentalt">

  <h2>home page.</h2>

  <p><?php 

  echo "Welcome {$_SESSION['User_firstname']} {$_SESSION['User_lastname']}";

  ?>

    to Unica Construction  website.   

  <p>

<p>You can view your current job status by clicking in the My Account section of the menu.

  <form id="form1" method="post" action="">

    <input type="submit" name="submit" id="submit" value="Job Status" />

    <input name="hiddenField" type="hidden" id="hiddenField" value="<?php echo $_SESSION['User_firstname']; ?>" />

    <input name="hiddenField2" type="hidden" id="hiddenField2" value="<?php echo $_SESSION['User_lastname']; ?>" />

    <table border="1">

      <tr>

        <td width="72">id</td>

        <td width="129">firstname</td>

        <td width="119">lastname</td>

        <td width="109">jobtype</td>

        <td width="57"> </td>

        <td width="58"> </td>

      </tr>

      <?php do { ?>

        <tr>

          <td><?php echo $row_rsJob['id']; ?>  </td>

          <td><a href="joddetails.php?recordID=<?php echo $row_rsJob['firstname']; ?>"> <?php echo $row_rsJob['firstname']; ?>  </a> </td>

          <td><?php echo $row_rsJob['lastname']; ?>  </td>

          <td><?php echo $row_rsJob['jobtype']; ?>  </td>

          <td><div align="center">Edit</div></td>

          <td><div align="center">Delete</div></td>

        </tr>

        <?php } while ($row_rsJob = mysql_fetch_assoc($rsJob)); ?>

    </table>

    <br />

    <table border="0">

      <tr>

        <td><?php if ($pageNum_rsJob > 0) { // Show if not first page ?>

              <a href="<?php printf("%s?pageNum_rsJob=%d%s", $currentPage, 0, $queryString_rsJob); ?>">First</a>

              <?php } // Show if not first page ?>

        </td>

        <td><?php if ($pageNum_rsJob > 0) { // Show if not first page ?>

              <a href="<?php printf("%s?pageNum_rsJob=%d%s", $currentPage, max(0, $pageNum_rsJob - 1), $queryString_rsJob); ?>">Previous</a>

              <?php } // Show if not first page ?>

        </td>

        <td><?php if ($pageNum_rsJob < $totalPages_rsJob) { // Show if not last page ?>

              <a href="<?php printf("%s?pageNum_rsJob=%d%s", $currentPage, min($totalPages_rsJob, $pageNum_rsJob + 1), $queryString_rsJob); ?>">Next</a>

              <?php } // Show if not last page ?>

        </td>

        <td><?php if ($pageNum_rsJob < $totalPages_rsJob) { // Show if not last page ?>

              <a href="<?php printf("%s?pageNum_rsJob=%d%s", $currentPage, $totalPages_rsJob, $queryString_rsJob); ?>">Last</a>

              <?php } // Show if not last page ?>

        </td>

      </tr>

    </table>

    Records <?php echo ($startRow_rsJob + 1) ?> to <?php echo min($startRow_rsJob + $maxRows_rsJob, $totalRows_rsJob) ?> of <?php echo $totalRows_rsJob ?>

  </form>

  <p>

</div>

<!-- InstanceEndEditable -->

<div id="sidebar">

  <h2>Welcome Message!</h2>

  <p>Thank for visitin our website please fell free to contact us anytime at 770-955-4533</p>

  <p>Thank you </p>

  <p>Unica Construction Staff.</p>

</div>

<div id="footer">

<p><a href="admin.php">home</a> | <a href="home.php">Admin</a> | <a href="myaccount.php">My Account</a> | <a href="clientmaster.php">Clients</a> | <a href="crewmaster.php">Staff</a> | <a href="logout.php">Logout</a><br />

© 2008 Unica Construction | Managed by <a href="http://www.admaxsolutions.com">Admaxsolutions.com</a></p>

</div>

 

</div>

</body>

<!-- InstanceEnd --></html>

<?php

mysql_free_result($rsclient);

 

mysql_free_result($rsJob);

?>

 

 

 

 

 

 

 

1) Please use code tags (the # sign icon).

 

2) Have you tried debugging the situation?  Echo out your variables in the query.

 

3) Could you give us the piece of code causing the issue so we don't have to read plain text.  It's probably your sql query.

Starters, this is not required

 

if (!isset($_SESSION)) {

  session_start();

}

 

 

 

session_start() will start a session if one is not started and resume one that is.

 

Onto your question, when you find your match in the DB for the user, store their ID in a session, then you can retrieve just that ID anytime you wish.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.