Jump to content

guyfromfl

Members
  • Posts

    286
  • Joined

  • Last visited

    Never

Posts posted by guyfromfl

  1. oh and the code for the $db->checkUser($username, $password); call

     

    dblib.php

    class dblib {
            // Other stuff
    
    function checkUser($user, $pass) {
    	/*
    	 * Description: Validate a user by his log in creditials.  A
    	 * 				user with user_id of zero is a normal web surfer
    	 * 				and cannot access company privilege info.
    	 * 
    	 * Date:		April 1, 2009
    	 */
            $sql = "SELECT id FROM bli.users WHERE
    				bli.users.username='$user' AND
    				bli.users.password=MD5('$pass')";
            $result = $this->query($sql);
    
            list($user_id) = mysql_fetch_row($result);
    
            if (empty($user_id)) {
                $user_id = 0;
            }
    
            return $user_id;
        }
       // More other stuff	
    }
    
    $db = new dblib();
    
    

  2. I cannot figure out why this login script will not work.  I have simply copied and pasted it from code that works.  If I ask it to return $_SESSION['user_id'] from inside login.php it echos the correct value.  If you put it anywhere else it says undefiened index.

     

    no matter what I get redirected to the login page.

     

    I don't think the $_SESSION data is getting passed to the other pages.

     

    PLEASE HELP

     

    pretty simple code snipets:

     

    header.php

    <?php
    
    include('includes/format.php');
    include('includes/dblib.php');
    
    $config = $db->getConfig();
    $format = new format();
    
    	session_start();
    
    ?>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    	<title>Broadway Limited Imports Service Department</title>
    	<link href="http://bli.servehttp.com/bli/knowledgebase/includes/bliprint.css" rel="stylesheet" type="text/css" media="print" />
    	<link href="includes/css/bli.css" type="text/css" rel="stylesheet" media="screen, tv, tty" />
    	<link href="http://bli.servehttp.com/bli/knowledgebase/includes/jquery-ui-1.7.2-custom.css" type="text/css" rel="stylesheet" />
    	<script src='lib/jquery/jquery.js' type="text/javascript"></script>
    	<script src='includes/corners.js' type="text/javascript"></script>
    	<script src='includes/ui.core.js' type="text/javascript"></script>
    	<script src='includes/ui.datepicker.js' type="text/javascript"></script>
    
    <!-- Functions -->
    	<script type="text/javascript">
    $(function() {
    $("#datepicker").datepicker();
    $("#format").change(function() { $('#datepicker').datepicker('yy-mm-dd', {dateFormat: $(this).val()}); });
    
    });
    	</script>
    
    </head>
    <body>
    <!-- <body onload="document.frmSearch.search.focus()"> -->
    	<!-- Begin Wrapper -->
    	<center>
    		<div id="wrapper">
    		<!-- Logged in Status -->
    <?php
    
    echo ($_SERVER['user_id']);
    if (isset($_SESSION['user_id'])) {
    	echo "<div style='float: right; font-size: 12px; padding-right: 10px; top:0' id='userPanel'>
    		  <span style='color: #777;'><a href='issueList.php'>Issue Tracker</a> | </span>
    		  <span style='color: #777;'><a href='admin/'>Admin Control Panel</a> | </span>   
    	      <a href='logout.php'>Logged in as " . $db->getUserfNameById($_SESSION['user_id']) .
    	     "</a></div>";
    } else {
    	echo "NOOOOOOOOOOOOOO";
    }
    
    ?>
    		<!-- Begin Header -->
    		<div id="header">
    			<p style="color:#ccc; valign: middle; text-align: left">
    				<a href="<?php echo $config['companyWebsite']; ?>"><img style="padding-left: 10px" src="img/HeaderLogo.png" alt="Broadway Limited Imports" /></a>
    				<a href="http://bli.servehttp.com">Knowledge Base</a>
    			</p>
    		</div>
    
    
    		</div>
    		<!-- End Header -->
    
    

     

     

    index.php

    <?php
    
    require('includes/header.php');
    
    //echo $_SESSION['user_id'];
    //die();
    
    if (isset($_SESSION['user_id'])) {
    ?>
    		<h3>Main Menu</h3>
    		<table id="menu">
    			<tr>
    				<td><img src='img/icons/128/Tools.png' /><br />Repairs</a></td>
    				<td><img src='img/icons/128/Components.png' /><br />Parts</a></td>
    			</tr>
    			<tr>
    				<td><img src='img/icons/128/Issue.png' /><br />Issues</td>
    				<td><a href='customer.php?action=menu'><img src='img/icons/128/Customers.png' /><br />Customers</a></td>
    
    			</tr>
    		</table>
    
    <?php
    } else {
    header("Location: login.php");
    }
    
    
    require('includes/footer.php'); 
    ?>
    
    
    

     

     

     

    login.php

    <?php
    
    require('includes/header.php');
    ?>
    
    <br /><br />
    <div id="login">
    
    <?php
    
    // Check if user wants to login
    if(isset($_GET['try'])) {
    
        // Check info was entered
        if(empty($_POST['username']) OR empty($_POST['password'])) {
        // not everything was entered
            echo "<span style='color: red'>Please fill in all the fields.</span>";
        } else {
            // Check credentials
            $username = mysql_real_escape_string($_POST['username']);
            //$password = md5($_POST['password']);
    	$password = $_POST['password'];
    
            $checkUser = $db->checkUser($username, $password);
    
            if ($checkUser == 0) {
                echo "<span style='color: red'>Invalid login!</span>";
            } else {
                // CREATE SESSION
                $_SESSION['user_id'] = $checkUser;
    		echo $_SESSION['user_id'];
    
                // $db->logUser();
                header("Location: index.php");
            }
        }
    }
    
    ?>
    <form action="login.php?try=validate" method="post">
    <p>
    <strong>Login<br /></strong>
    Username: <input type="text" name="username" class="login" /><br />
    <br />
    Password: <input type="password" name="password" class="login" /><br />
    <br />
    <input type="submit" value="Login" />
    </p>
    </form>
    </div><br /><br />
    </div>
    <?php
    include ('includes/footer.php');
    ?>
    
    

  3. I am trying to make it so you can click the checkbox at the top, and it will hide all rows where the data of the Status column is "Complete"

     

    I am trying to decide the best way to do it, either check the data that is in the innerHtml, or like I have now, php determines what the value from the database is and adds class='complete' to the tr tag.

     

    Any suggestions?

     

    Here is the test table:

    http://bli.servehttp.com/bli/knowledgebase/issueList.php

  4. Yea I know about JS to do that, but what I was working towards would be a more complex table where you can change the status by clicking the row and a few other things that would rely on the database.  I figured starting with the hide might be a good baby step.  I definatly could be wrong about that  :P

  5. You're mixing html and php code all over the place.

     

    record 1

    Name=

    FirstName=Joe Bob

     

    record 2

    Name=Billy Bob

    FirstName=

     

    record3

    Name=Peggy Sue

    FirstName=Peggy

     

    echo "<b>Database Contents</b>";
    
    foreach ($rec as $record) {
       if ($Name) {
          echo "Name: " . $Name[$rec] . <br />";
       }
    
       if ($FirstName) {
          echo "First Name: " . $FirstName[$rec];
       }
    
       echo "<br />";
    }
    
    

     

    Is that what you are looking for?

  6. yum only gives you packages for the distro you have plus i think the previous 2.  so if you are using distro 7 but latest is 10 you cant get anything through yum any more.

×
×
  • 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.