Results 1 to 2 of 2

Thread: I cant output specific database. Please help.

  1. #1
    Join Date
    Aug 2015
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question I cant output specific database. Please help.

    SORRY FOR MY BAD ENGLISH.
    I CAN DO MY LOGIN PROGRAM BUT I CANT OUT INDIVIDUAL INFORMATION.

    this is my login program


    Code:
    <?php require_once('Connections/Connection.php'); ?>
    <?php
    if (!function_exists("GetSQLValueString")) {
    function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
    {
      if (PHP_VERSION < 6) {
        $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;
    }
    }
    
    mysql_select_db($database_Connection, $Connection);
    $query_datalogin = "SELECT * FROM users";
    $datalogin = mysql_query($query_datalogin, $Connection) or die(mysql_error());
    $row_datalogin = mysql_fetch_assoc($datalogin);
    $totalRows_datalogin = mysql_num_rows($datalogin);
    ?>
    <?php
    // *** Validate request to login to this site.
    if (!isset($_SESSION)) {
      session_start();
    }
    
    $loginFormAction = $_SERVER['PHP_SELF'];
    if (isset($_GET['accesscheck'])) {
      $_SESSION['PrevUrl'] = $_GET['accesscheck'];
    }
    
    if (isset($_POST['username'])) {
      $loginUsername=$_POST['username'];
      $password=$_POST['password'];
      $MM_fldUserAuthorization = "Userslevel";
      $MM_redirectLoginSuccess = "test-members.php";
      $MM_redirectLoginFailed = "test-login.php";
      $MM_redirecttoReferrer = false;
      mysql_select_db($database_Connection, $Connection);
      	
      $LoginRS__query=sprintf("SELECT UserName, Password, Userslevel FROM users WHERE UserName=%s AND Password=%s",
      GetSQLValueString($loginUsername, "text"), GetSQLValueString($password, "int")); 
       
      $LoginRS = mysql_query($LoginRS__query, $Connection) or die(mysql_error());
      $loginFoundUser = mysql_num_rows($LoginRS);
      if ($loginFoundUser) {
        
        $loginStrGroup  = mysql_result($LoginRS,0,'Userslevel');
        
    	if (PHP_VERSION >= 5.1) {session_regenerate_id(true);} else {session_regenerate_id();}
        //declare two session variables and assign them
        $_SESSION['MM_Username'] = $loginUsername;
        $_SESSION['MM_UserGroup'] = $loginStrGroup;	      
    
        if (isset($_SESSION['PrevUrl']) && false) {
          $MM_redirectLoginSuccess = $_SESSION['PrevUrl'];	
        }
        header("Location: " . $MM_redirectLoginSuccess );
      }
      else {
        header("Location: ". $MM_redirectLoginFailed );
      }
    }
    ?>
    <!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>Untitled Document</title>
    </head>
    
    <body>
    <form id="form1" name="form1" method="POST" action="<?php echo $loginFormAction; ?>">
      <label for="username">Username :</label>
      <input type="text" name="username" id="username" />
      <br />
      <label for="password">Password :</label>
      <input type="password" name="password" id="password" />
      <br />
      <input type="submit" name="btnlogin" id="btnlogin" value="Log in!!" />
    </form>
    </body>
    </html>
    <?php
    mysql_free_result($datalogin);
    ?>
    AND THIS IS ALREADY LOGIN.

    Code:
    <?php require_once('Connections/Connection.php'); ?>
    <?php
    if (!function_exists("GetSQLValueString")) {
    function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
    {
      if (PHP_VERSION < 6) {
        $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;
    }
    }
    
    mysql_select_db($database_Connection, $Connection);
    $query_datauser = "SELECT * FROM users";
    $datauser = mysql_query($query_datauser, $Connection) or die(mysql_error());
    $row_datauser = mysql_fetch_assoc($datauser);
    $totalRows_datauser = mysql_num_rows($datauser);
    ?>
    <!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">
    <?php session_start(); ?>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Untitled Document</title>
    </head>
    
    <body>
    <p><?php echo $_SESSION['MM_Username']; ?>
    </p>
    
    <p>&nbsp;</p>
    </body>
    </html>
    <?php
    mysql_free_result($datauser);
    ?>
    I would like to show just his information.
    for example when i log in to Usename : potato i just want to show his BANK , PVSELF , PVCOLLECT , ect
    for example when i log in to Usename : toohoo i just want to shouw his BANK , PVSELF : 500 , PVCOLLECT = 0 : ect just only one profile
    I did it but i only can show all of these profile but i cant show just only what i want.
    sorry for my bad english






    if i wanna show just his detail what should i do ? THX FOR ADVANCE
    Last edited by james438; 08-30-2015 at 10:15 PM. Reason: code formatting

  2. #2
    Join Date
    Jan 2007
    Location
    Davenport, Iowa
    Posts
    1,875
    Thanks
    92
    Thanked 97 Times in 95 Posts

    Default

    I wish I could help you here, but user defined functions are often tricky for me and I seldom use them.

    Your second post is a little unclear. Could you elaborate?

    Usually when I want to pull just one row from the database I will use something like

    SELECT * FROM users WHERE member = 'toohoo'

    In the above you are using the deprecated mysql_escape_string and the also deprecated mysql_real_escape_string. You should use mysqli_real_escape_string instead. Before that you should strongly consider upgrading to MySQLi from MySQL.
    To choose the lesser of two evils is still to choose evil. My personal site

Similar Threads

  1. form - show a specific thing if another specific thing is entered
    By asdfqwerty in forum Looking for such a script or service
    Replies: 12
    Last Post: 10-15-2010, 06:36 PM
  2. specific output from sql
    By gurmeet in forum MySQL and other databases
    Replies: 6
    Last Post: 01-08-2010, 02:31 PM
  3. Resolved output array
    By bluewalrus in forum PHP
    Replies: 0
    Last Post: 10-20-2009, 07:30 PM
  4. PHP output
    By wibumba in forum PHP
    Replies: 4
    Last Post: 02-26-2008, 12:32 AM
  5. 1 + 1 will output 11 and not 2...
    By Dennis_Gull in forum JavaScript
    Replies: 10
    Last Post: 07-04-2007, 05:12 PM

Bookmarks

Posting Permissions

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