www.webdeveloper.com
Results 1 to 3 of 3

Thread: Client Database

Hybrid View

  1. #1
    Join Date
    Jun 2011
    Posts
    4

    Unhappy Client Database

    We have our site about 40 pages build with DW CS5.5 using .PHP

    I can not find any tut or treads on building a database that will let:
    1. lets clients log in and edit there information, receive communication from registered employee users, submit service request, check note on requests

    and
    2. have a log in for employees who can register users for the first time, can search for and then view information about users, personal data, can look at all open request submitted by users and reed notes to see what has been done to complete the request for that client.

    I can get a basic page going but all clients seem to see that same thing once logged in not there personal info..and i cant find anything on making the database searchable by one level not the other ( ie employee not client) and then let members see there information


    Thanks in Advance everyone
    Sorry if this seem like a nob i have not done much with database yet so im trying hard to learn ))))

  2. #2
    Join Date
    May 2011
    Location
    With Hobbits
    Posts
    125

    Talking

    The way i display personal information is like this

    Code:
    <?php
    
    $sql = "SELECT column FROM `table` WHERE `username`= '$name' ";
    $result = mysql_query($sql);
    
    if (!$result) {
        echo "Could not successfully run query ($sql) from DB: " . mysql_error();
        exit;
    }
    
    while($row = mysql_fetch_assoc($result)) {
         $src = '';
         switch( $row['column'] ) {
              case '0':
                  $src = 'admin/user.png';
                  break;
              case '1':
                  $src = 'admin/admin.png';
                  break;
              default:
                  $src = 'admin/user.png';
          }
          ?><img id="imgcont" src="<?php echo $src; ?>" /><?php
    	
    }
    ?>
    this is of course to display images based on a mysql db value.When an account is created it adds a value of ither 0 or 1 to a column in my table. Upon loading if there account has a 0 it will show an image that says user. If it is a 1 it will show an image that says Admin and i also use the same value to allow certain things like control over an admin panel.

    you may be wondering how that relates to a single account well it does it all via $name. $name is a variable for a cookie grabbed like so at the head of all my pages

    Code:
    $name=$_COOKIE["ID_my_site"];
    if(isset($_POST['ID_my_site']))
    $name=$_POST['ID_my_site'];
    and the cookie is set using this code at login.

    Code:
     $_POST['username'] = stripslashes($_POST['username']); 
    
     $hour = time() + 50400; 
    
     setcookie(ID_my_site, $_POST['username'], $hour); 
    
     setcookie(Key_my_site, $_POST['pass'], $hour);
    of course once you go into this if you are using sessions you have to switch to checking based on cookies, i prefer cookies and im not really sure how this would work if using sessions so i cant really help you much there.

    so if you are not trying to display an image and just a certain accounts information i would do it like this

    Code:
    <?php
    $sql= "SELECT * FROM `table` WHERE `username` = '$name' ";
    
            $result=mysql_query($sql)
            {   
                           
               $row = mysql_fetch_row($result)
                {
    	        $WhatEver0 = $row[0];
    	        $WhatEver1 = $row[1];
                    $WhatEver2 = $row[2];
                 }
    						
             }
    ?>
    *you will have to change this to fit your mysql db*
    and than you would display that information in your html by using php echo

    Code:
    <label for="something"><?php echo $WhatEver0; ?></label>
    
    <input type = "text" id="input1" value="<?php echo $WhatEver1; ?>">
    also dont forget to include your db connection that is if your even using a db lol XD

    sorry if its a bit confusing
    Last edited by Nvenom; 06-17-2011 at 05:32 PM.

  3. #3
    Join Date
    Feb 2007
    Location
    Thailand
    Posts
    75
    Why don't you try to search for source code repositories on GitHub or Bitbucket

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles