Page 1 of 1

still need help creating an accounts page

Posted: Wed Jul 16, 2008 5:55 pm
by ninja2222
How do I set up a customer accounts page. I have the authentication page all figured out.

I want my users to be able click on links to excel files that are strictly pertinent to their account?

How is this possible?

This is the other thread that I was getting help with, and I'm still lost

viewtopic.php?f=6&t=85474

I will also like to make an update page. How can I create this? My guess was that I would use a MySQL database, and php. I don't know what to do any more.

Code: Select all

 
<?php require_once('Connections/connex.php'); ?>
<?php
//initialize the session
session_start();
 
// ** Logout the current user. **
$logoutAction = $HTTP_SERVER_VARS['PHP_SELF']."?doLogout=true";
if ((isset($HTTP_SERVER_VARS['QUERY_STRING'])) && ($HTTP_SERVER_VARS['QUERY_STRING'] != "")){
  $logoutAction .="&". $HTTP_SERVER_VARS['QUERY_STRING'];
}
 
if ((isset($HTTP_GET_VARS['doLogout'])) &&($HTTP_GET_VARS['doLogout']=="true")){
  //to fully log out a visitor we need to clear the session varialbles
  session_unregister('MM_Username');
  session_unregister('MM_UserGroup');
    
  $logoutGoTo = "adminlogin.php";
  if ($logoutGoTo) {
    header("Location: $logoutGoTo");
    exit;
  }
}
?>
<?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 = "adminlogin.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_username = "-1";
if (isset($_SESSION['MM_Username'])) {
  $colname_username = $_SESSION['MM_Username'];
}
mysql_select_db($database_connex, $connex);
$query_username = sprintf("SELECT * FROM customerup WHERE username = %s", GetSQLValueString($colname_username, "text"));
$username = mysql_query($query_username, $connex) or die(mysql_error());
$row_username = mysql_fetch_assoc($username);
$totalRows_username = mysql_num_rows($username);
$colname_Recordset1 = "-1";
if (isset($_SESSION['pkid'])) {
  $colname_Recordset1 = $_SESSION['pkid'];
}
mysql_select_db($database_connex, $connex);
$query_Recordset1 = sprintf("SELECT * FROM files WHERE pkid = %s", GetSQLValueString($colname_Recordset1, "int"));
$Recordset1 = mysql_query($query_Recordset1, $connex) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
 
 
?>
<!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>A-LINE MESSENGER SERVICE UCLA ETA AND ROUTE TRACKING</title>
<script type="text/javascript">
function MM_CheckFlashVersion(reqVerStr,msg){
  with(navigator){
    var isIE  = (appVersion.indexOf("MSIE") != -1 && userAgent.indexOf("Opera") == -1);
    var isWin = (appVersion.toLowerCase().indexOf("win") != -1);
    if (!isIE || !isWin){  
      var flashVer = -1;
      if (plugins && plugins.length > 0){
        var desc = plugins["Shockwave Flash"] ? plugins["Shockwave Flash"].description : "";
        desc = plugins["Shockwave Flash 2.0"] ? plugins["Shockwave Flash 2.0"].description : desc;
        if (desc == "") flashVer = -1;
        else{
          var descArr = desc.split(" ");
          var tempArrMajor = descArr[2].split(".");
          var verMajor = tempArrMajor[0];
          var tempArrMinor = (descArr[3] != "") ? descArr[3].split("r") : descArr[4].split("r");
          var verMinor = (tempArrMinor[1] > 0) ? tempArrMinor[1] : 0;
          flashVer =  parseFloat(verMajor + "." + verMinor);
        }
      }
      // WebTV has Flash Player 4 or lower -- too low for video
      else if (userAgent.toLowerCase().indexOf("webtv") != -1) flashVer = 4.0;
 
      var verArr = reqVerStr.split(",");
      var reqVer = parseFloat(verArr[0] + "." + verArr[2]);
  
      if (flashVer < reqVer){
        if (confirm(msg))
          window.location = "http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash";
      }
    }
  } 
}
</script>
<script src="Scripts/AC_RunActiveContent.js" type="text/javascript"></script>
<style type="text/css">
<!--
body,td,th {
    font-family: Arial Black, Arial, sans-serif;
    font-size: medium;
    color: #FFFFFF;
}
body {
    background-color: #000066;
    margin-left: 0px;
    margin-top: 0px;
    margin-right: 0px;
    margin-bottom: 0px;
}
#container {
    background-color: #000066;
    width: 780px;
    margin-right: auto;
    margin-left: auto;
    border: thin solid #333333;
}
.style1 {color: #FF0000}
#container #top {
    font-family: "Arial Black", Arial, sans-serif;
    font-size: larger;
    font-style: oblique;
    font-weight: bolder;
    font-variant: small-caps;
    color: #FF0000;
    background-color: #FFFFFF;
    border: thick solid #313031;
    width: 770px;
}
a {
    font-family: Arial Black, Arial, sans-serif;
    font-size: medium;
    color: #FFFF00;
}
#nav {
    background-color: #333333;
    text-align: center;
    padding: 10px;
    border: thin solid #000000;
}
#form1 table {
    background-color: #313031;
    border: thin solid #000000;
}
#nav ul {
    margin: 0px;
    padding: 0px;
}
#nav li {
    list-style-type: none;
    display: inline;
    margin-right: 10px;
    margin-left: 10px;
}
#nav a {
    font-size: 90%;
    text-decoration: none;
}
#nav a:hover {
    color: #FF0000;
    font-size: 90%;
    text-decoration: none;
}
#container #footer {
    height: auto;
    background-color: #333333;
}
#lower_links ul {
    margin: 0px;
    padding: 0px;
}
#lower_links li {
    list-style-type: none;
    display: inline;
    margin-right: 10px;
    margin-left: 10px;
}
#lower_links a {
    font-size: 90%;
    text-decoration: none;
}
#lower_links a:hover {
    color: #FF0000;
    font-size: 90%;
    text-decoration: none;
}
.style2 {
    font-family: Georgia, "Times New Roman", Times, serif;
    color: #FFFF00;
    font-style: italic;
}
.style3 {
    color: #FFFFFF;
    font-style: italic;
}
.style12 {font-size: small}
#log-in {   padding: 0px;
    width: 229px;
    margin-top: 0px;
    margin-bottom: 0px;
    margin-left: 20px;
    float: right;
}
#logtable {
    background-color: #313031;
    border-right-width: thin;
    border-bottom-width: thin;
    border-left-width: thin;
    border-right-style: solid;
    border-bottom-style: solid;
    border-left-style: solid;
    border-right-color: #000000;
    border-bottom-color: #000000;
    border-left-color: #000000;
}
.style13 {color: #FFFF00}
#customername {
    font-family: Arial, Helvetica, sans-serif;
    font-size: large;
    color: #FF0000;
    font-style: oblique;
    text-decoration: underline;
}
#files {
    font-family: Arial, Helvetica, sans-serif;
    font-size: medium;
    font-style: oblique;
    font-weight: bold;
    color: #FFFF00;
    text-align: center;
}
-->
</style>
</head>
 
 
<div id="container">
  <img src="images/ALM.gif" name="top" width="780" height="65" id="top" />
  <div id="nav">
    <ul>
      <li><a href="/index.html">Home</a></li>
      <li><a href="/about_us.html">About Us</a></li>
      <li><a href="/delivery_services.html">Services</a></li>
      <li><a href="/on_line_order.html">Place Order</a></li>
      <li><a href="adminlogin.php">Tracking/Reports</a></li>
      <li><a href="/contact_us.html">Contact Us</a></li>
      <li><a href="/links.html">Links</a></li>
    </ul>
  </div>
  <div align="center" id="log-in">
    
    <div align="right">
<table width="228" border="0" cellpadding="0" id="logtable">
          <tr>
            <td height="68" colspan="2" bordercolor="#FFFFFF" id="form2"><span class="style12">
              <label></label>
                          </span>
              <span class="style12"></span>
              <label> </label>
              <div align="center">
                <p><span class="style13">Logged In</span><br />
                  <a href="<?php echo $logoutAction ?>" class="style12">Log out</a></p>
            </div></td>
          </tr>
      </table>
    </div>
  </div>
  <div id="body">
  
    <h2 align="right"><span class="style2">TRACKING & REPORTS<br />
      <br />
    </span></h2>
    <?php if ($totalRows_username > 0) { // Show if recordset not empty ?>
      <?php } // Show if recordset not empty ?>
<div id="customername">
        <div align="center">
          <h3><?php echo $row_username['menu_name']; ?></h3>
        </div>
    </div>
      
      
      
    <h3 align="center"><br />
    <span class="style13"><em>CUSTOMER ACCOUNT FILES</em></span></h3>
    
    <?php if ($totalRows_Recordset1 > 0) { // Show if recordset not empty ?>
      <div id="files"><?php echo $row_Recordset1['clientid']; ?></div>
      <?php } // Show if recordset not empty ?>
<p align="center">&nbsp;</p>
  </div>
 
  <div id="footer"><div id="nav">
 
    <ul>
      <li><a href="/index.html">Home</a></li>
      <li><a href="/about_us.html">About Us</a></li>
      <li><a href="/delivery_services.html">Services</a></li>
      <li><a href="/on_line_order.html">Place Order</a></li>
      <li><a href="adminlogin.php">Tracking/Reports</a></li>
      <li><a href="/contact_us.html">Contact Us</a></li>
      <li><a href="/links.html">Links</a></li>
    </ul>
  </div>
    <!--end of the footer div -->
  </div>
  <h4 align="center"><em><span class="style1">A-LINE MESSENGER SERVICE </span></em><span class="style3">- 2 - DELIVER - 4 - YOU</span><em>!</em></h4>
</div>
<!--this is the close of the container div--></body>
<?php
mysql_free_result($username);
 
mysql_free_result($Recordset1);
?>

Re: still need help creating an accounts page

Posted: Mon Jul 21, 2008 6:58 pm
by dyluck
Well... the easiest way I could think of is using a database to store the locations of the excel files and set a variable in the database that you could link to a unique user variable.
This way you can set a query to the database for the excel files pertinant to that user.

User's Name | userid
/
userid | file location 1
userid | file location 2 etc



hope that helps with that question.

What do you mean by an "update page"?

Re: still need help creating an accounts page

Posted: Tue Jul 22, 2008 2:06 pm
by ninja2222
Ok, but then how do you show the file as a link.

Re: still need help creating an accounts page

Posted: Tue Jul 22, 2008 3:08 pm
by Chalks
dyluck wrote: userid | file location 1
userid | file location 2 etc
ninja2222 wrote:Ok, but then how do you show the file as a link.

Code: Select all

<?php
$db = mysql_connect("hostname", "username", "password");
mysql_select($db);
 
$sql = "SELECT fileLocation FROM myTable WHERE userid=12345";
$result = mysql_query($sql) or die(mysql_error());
$data = mysql_fetch_assoc($result);
 
if(!empty($data))
  echo "<a href=\"$data[0]\">Excel File</a>";
 
mysql_close($db);
?>
This will retrieve just one file. If the user has more than one entry in the table, then you would have to loop through the $data with a while loop.

Re: still need help creating an accounts page

Posted: Sat Jul 26, 2008 6:54 pm
by dyluck
Sorry i didn't get back to you sooner.
You have to use a mysql_fetch_array()

Code: Select all

<?php
$db = mysql_connect("hostname", "username", "password");
mysql_select($db);
 
$sql = "SELECT fileLocation,name FROM myTable WHERE userid=12345";
$result = mysql_query($sql) or die(mysql_error());
while($row = mysql_fetch_array($result))
 {
$filelocation = $row['fileLocation'];
$name = $row['name'];
 
//echo the array. 
echo '<a href="'.$filelocation.'">'.$name.'</a><br>';
 
}
 
mysql_close($db);
?>
That should return something like

Excel Spreadsheet1
Excel Spreadsheet2
Excel Spreadsheet3

All as its separate link to each location so on and so forth.

Hope that helps a little. Post more if you have more questions.