Jump to content

9911782

Members
  • Posts

    39
  • Joined

  • Last visited

    Never

Posts posted by 9911782

  1. Just need logic for doing this.Im desparate really. When do I register these trasanction to DB. Can you please expand for me please. 

    I am making the following assumptions:

     

    1.  All users must be logged in to make alterations

    2.  The updates are done through forms

    3.  User ID is stored in a session

     

     

    Based on this, here is how I would do it:

     

    1. New db table to store transactions with following fields:

        - transID (unique ID number)

        - userID (obtained from session)

        - transtype (determined by the form modified)

        - transdatetime (timestamp)

     

    2.  When a user modifies a form, e.g. their profile, we need to have a hidden field for the transaction type, e.g. <input type="hidden" name="transtype" value="profile" />.

     

    3.  When posting the change, an Insert query (in addition to the query that updates) is done to the transaction table which assigns a unique transID grabs the userID from session, and the transtype from POST and timestamps NOW()

     

    e.g.

    $userID = $_SESSION['userID'];
    $transtype = $_POST['transtype'];
    $sql = mysql_query("INSERT INTO tbltrans (transID, userID, transtype, transdatetime) VALUES ('', '$userID', '$transtype', NOW());
    

     

    This is just a very brief overview.  If you need more details let me know and I will be happy to expand.

     

  2. Hi

    I would like you to help me here, now sure if this should go under PHP Help or MySQL Help...

     

    I need help regarding Audit Trail. Im expected to do An audit trail that must be kept of access to the system as well as of all create and update transactions to the database.  This implies the details of the relevant person(s) who transacted as well as time and date of transactions.  This does not apply to the load process – only to the user intervention in the system.

     

    Can somebody run me through the steps I should take to do this for my application.

     

    Thanks

    D

     

  3. Hi HaLo2FrEeEk

     

    I dont understand you now. Because the code I posted here is the very same post that is giving me the errors I posted.Here is the Code:

     

    Here is My code:

    ==================

    <?php //@Language=VBScript?>

    <?php include("../Connections/fetwebsite.php");

    if($_REQUEST["enter"]=="yes" ){

      include("../connections/fetwebsite.php");

          $sql="select MAX(ImageID) as maximageid from galleryImages";

          //execute sql statements

          $rsUsers = mysql_query($sql, $fetcolleges) or die(mysql_error());

          $rows_rsUsers = mysql_fetch_assoc($rsUsers);

          $total_num_Users = mysql_num_rows($rsUsers);

      $maximageid = $rows_rsUsers['maximageid'];

      $GalleryID = $_REQUEST['GalleryID'];

      $ImageID=$_REQUEST["ImageID"];

      $Caption = $_POST["caption"];

      $GalleryID = $_POST['GalleryID'];

      $ImageStatus = $_POST['ImageStatus']; 

      $ImageFull = $_FILES['ImageFull']['ImageFull'];

      $tmpNameFull  = $_FILES['ImageFull']['tmp_name'];

      $ImageThumb = $_FILES['ImageThumb']['ImageThumb'];

        $tmpNameThumb  = $_FILES['ImageThumb']['tmp_name'];

        $fileName = $_FILES['ImageThumb']['name'];

      $tmpName  = $_FILES['ImageThumb']['tmp_name'];

      $tmpName2  = $_FILES['ImageThumb']['tmp_name'];   

        $file_size = $_FILES['ImageThumb']['size'];

        $fileType = $_FILES['ImageThumb']['type'];

      $DateAdded=date("Y/m/d H:i:s"); 

      // you can change this to any directory you want

      // as long as php can write to it

      $uploadDir = '../photogalleries/';

      //$DefaultPasswords['program'] = crypt('program');

        // the files will be saved in filePath 

      /// $filePath = $uploadDir . $fileName;

      $maximageid = $maximageid + 1;

      $ImageThumb = "thumb"."_".$maximageid."."."jpg";

      $ImageFull =  "photo"."_".$maximageid."."."jpg";

        $filePath = $uploadDir . $fileName;

      $filePath2 = $uploadDir . $ImageThumb;

      $filePath3 = $uploadDir . $ImageFull;

     

      ///RESIZE THUMBNAIL///

      // Set a maximum height and width

      $width = 115;

      $height = 147;

     

      // Get new dimensions

      list($width_orig, $height_orig) = getimagesize($filePath);

      $ratio_orig = $width_orig/$height_orig;

     

      if ($width/$height > $ratio_orig) {

          $width = $height*$ratio_orig;

      } else {

          $height = $width/$ratio_orig;

      }

      // Resample

      $image_p = imagecreatetruecolor($width, $height);

      $image = @imagecreatefromjpeg($filePath);

      imagecopyresampled($image_p, $image, 0, 0, 0, 0, $width, $height, $width_orig, $height_orig);

     

      // Output

      $thumbsize = imagejpeg($image_p, null, 100);

      $thumbsize;

      if (function_exists('imagecreatefromjpeg') || function_exists('imagecreatetruecolor') || function_exists('imagecopyresampled') || function_exists('getimagesize')) {

      echo 'OK, you already have GD library installed';

      } else {

          echo 'Sorry, it seem that GD library is not installed/enabled';

      }

      ///END RESIZE THUMBNAIL///

        // move the files to the specified directory

        // if the upload directory is not writable or

        // something else went wrong $result will be false   

      //$result    = move_uploaded_file($tmpName, $filePath);   

      $result1    = move_uploaded_file($tmpNameThumb, $filePath3);

      $result2    = move_uploaded_file($tmpNameFull, $filePath2);         

     

        if(!get_magic_quotes_gpc())

        {

          $fileName  = addslashes($fileName);

          $filePath  = addslashes($filePath);

        }

     

      $uploadDir = '../photogalleries/$fileName';

     

      $sql="INSERT INTO galleryImages(Caption,GalleryID, ImageStatus, name,size, type, path,DateAdded,ImageThumb,ImageFull) values ('$Caption','".$_REQUEST['GalleryID']."','$ImageStatus','$fileName', '$file_size', '$fileType', '$filePath','$DateAdded','$ImageThumb','$ImageFull')";

      $execute = mysql_query($sql, $fetcolleges) or die(mysql_error());

      if($execute){             

          mysql_close($fetcolleges);

          //header("Location: galleryImages_setup.php");     

      }

    }

    ?>

    ==================

     

    Can you explain more about what you mean?

  4. Hi

     

    I've been trying to Uploading Images/create Thumbnails to insert into my DB. I get so many errors when running this code.

     

    Here is My code:

    ==================

    <?php //@Language=VBScript?>

    <?php include("../Connections/fetwebsite.php");

    if($_REQUEST["enter"]=="yes" ){

    include("../connections/fetwebsite.php");

    $sql="select MAX(ImageID) as maximageid from galleryImages";

    //execute sql statements

    $rsUsers = mysql_query($sql, $fetcolleges) or die(mysql_error());

    $rows_rsUsers = mysql_fetch_assoc($rsUsers);

    $total_num_Users = mysql_num_rows($rsUsers);

    $maximageid = $rows_rsUsers['maximageid'];

    $GalleryID = $_REQUEST['GalleryID'];

    $ImageID=$_REQUEST["ImageID"];

    $Caption = $_POST["caption"];

    $GalleryID = $_POST['GalleryID'];

    $ImageStatus = $_POST['ImageStatus'];

    $ImageFull = $_FILES['ImageFull']['ImageFull'];

    $tmpNameFull  = $_FILES['ImageFull']['tmp_name'];

    $ImageThumb = $_FILES['ImageThumb']['ImageThumb'];

    $tmpNameThumb  = $_FILES['ImageThumb']['tmp_name'];

        $fileName = $_FILES['ImageThumb']['name'];

    $tmpName  = $_FILES['ImageThumb']['tmp_name'];

    $tmpName2  = $_FILES['ImageThumb']['tmp_name']; 

        $file_size = $_FILES['ImageThumb']['size'];

        $fileType = $_FILES['ImageThumb']['type'];

    $DateAdded=date("Y/m/d H:i:s");

    // you can change this to any directory you want

    // as long as php can write to it

    $uploadDir = '../photogalleries/';

    //$DefaultPasswords['program'] = crypt('program');

        // the files will be saved in filePath 

      /// $filePath = $uploadDir . $fileName;

      $maximageid = $maximageid + 1;

      $ImageThumb = "thumb"."_".$maximageid."."."jpg";

      $ImageFull =  "photo"."_".$maximageid."."."jpg";

        $filePath = $uploadDir . $fileName;

      $filePath2 = $uploadDir . $ImageThumb;

      $filePath3 = $uploadDir . $ImageFull;

     

      ///RESIZE THUMBNAIL///

      // Set a maximum height and width

    $width = 115;

    $height = 147;

     

    // Get new dimensions

    list($width_orig, $height_orig) = getimagesize($filePath);

    $ratio_orig = $width_orig/$height_orig;

     

    if ($width/$height > $ratio_orig) {

      $width = $height*$ratio_orig;

    } else {

      $height = $width/$ratio_orig;

    }

    // Resample

    $image_p = imagecreatetruecolor($width, $height);

    $image = @imagecreatefromjpeg($filePath);

    imagecopyresampled($image_p, $image, 0, 0, 0, 0, $width, $height, $width_orig, $height_orig);

     

    // Output

    $thumbsize = imagejpeg($image_p, null, 100);

    $thumbsize;

    if (function_exists('imagecreatefromjpeg') || function_exists('imagecreatetruecolor') || function_exists('imagecopyresampled') || function_exists('getimagesize')) {

      echo 'OK, you already have GD library installed';

    } else {

      echo 'Sorry, it seem that GD library is not installed/enabled';

    }

    ///END RESIZE THUMBNAIL///

        // move the files to the specified directory

        // if the upload directory is not writable or

        // something else went wrong $result will be false   

    //$result    = move_uploaded_file($tmpName, $filePath); 

    $result1    = move_uploaded_file($tmpNameThumb, $filePath3);

    $result2    = move_uploaded_file($tmpNameFull, $filePath2); 

     

        if(!get_magic_quotes_gpc())

        {

          $fileName  = addslashes($fileName);

          $filePath  = addslashes($filePath);

        }

     

    $uploadDir = '../photogalleries/$fileName';

     

    $sql="INSERT INTO galleryImages(Caption,GalleryID, ImageStatus, name,size, type, path,DateAdded,ImageThumb,ImageFull) values ('$Caption','".$_REQUEST['GalleryID']."','$ImageStatus','$fileName', '$file_size', '$fileType', '$filePath','$DateAdded','$ImageThumb','$ImageFull')";

    $execute = mysql_query($sql, $fetcolleges) or die(mysql_error());

    if($execute){

    mysql_close($fetcolleges);

    //header("Location: galleryImages_setup.php");

    }

    }

    ?>

    ==================

     

    These are the errors I get:

     

    =======

    Warning: getimagesize(../photogalleries/darkie_02.jpg) [function.getimagesize]: failed to open stream: No such file or directory in C:\Program Files\Business Objects\ThirdParties\apache\htdocs\fetcolleges\admin\galleryImages_upload.php on line 68

     

    Warning: Division by zero in C:\Program Files\Business Objects\ThirdParties\apache\htdocs\fetcolleges\admin\galleryImages_upload.php on line 70

     

    Warning: imagecreatetruecolor() [function.imagecreatetruecolor]: Invalid image dimensions in C:\Program Files\Business Objects\ThirdParties\apache\htdocs\fetcolleges\admin\galleryImages_upload.php on line 78

     

    Warning: imagecopyresampled(): supplied argument is not a valid Image resource in C:\Program Files\Business Objects\ThirdParties\apache\htdocs\fetcolleges\admin\galleryImages_upload.php on line 80

     

    Warning: imagejpeg(): supplied argument is not a valid Image resource in C:\Program Files\Business Objects\ThirdParties\apache\htdocs\fetcolleges\admin\galleryImages_upload.php on line 83

    ============

     

    I have GD library installed, and check the php.ini all is well, but still getting this erros. I dont know what to do now.

     

    Ps help me!

     

     

  5. Hi All 

     

    Can somebody ps send me the php script that could help me to be able to kick out(time-out) users out of the page once they dont take the action for 5mins.

    _________________

    Thank you for your Help 

     

    9911782

  6. Hi bqallover

    Thank you very much for ur quick response.

    I have manage to get the code http://www.plus2net.com, but Im still faced with small problems.
    According to you tips. I have done these:

    1. Storing the login information in a table called active_users_online
    username,userid, session,time logged in, username, and status(ON/Off).
    2. Updating the status of the member, where I have the status stored in in
    active_users_online where I have set the status to ON by defualt. Now I have to update this status to ON and update the new time (field name tm) on every time the member opens inside the member area.
    3. When click logged out, change the system status to OFF and destroy the session. I have the problem with this part because when click logout, now the status doesnt change to status="off".
    4. Then I display who are active at site. Which is where my problem is, because it only shows the 1st user even though I loop them.



    here is my code:
    ----------------------------------------------------------------------
    <?php
    $session=session_id();
    $time=time();
    $time_check=$time-600; //SET TIME 10 Minute

    //open connection to the database
    require_once('inc_conn.php');
    // prepare query
    $sql="SELECT * FROM active_users_online WHERE session = '".$session."'";
    //execute sql statements
    $sessions = mysql_query($sql, $connwmis) or die(mysql_error());
    //retrieve one row of records
    $rows_sessions = mysql_fetch_array($sessions);
    //determine the number of records in recordset
    $num_rows = mysql_num_rows($sessions);
    if($num_rows=="0"){
    $time=date("y-m-d");
    $sql1="INSERT INTO active_users_online(session, timestamp,username,ip)VALUES('$session', '$time','".$_SESSION['svusername']."','".$_SESSION['svip']."')";
    $result1 = mysql_query($sql1, $connwmis) or die(mysql_error());
    }
    else {
    $time=date("y-m-d");
    $sql2="UPDATE active_users_online SET timestamp='$time', status='ON' WHERE session = '$session'";
    $result2 = mysql_query($sql2, $connwmis) or die(mysql_error());
    }



    $sql3 = "SELECT * FROM  active_users_online";
    $result3 = mysql_query($sql3, $connwmis) or die(mysql_error());

    $count_user_online=mysql_num_rows($result3);



    // if over 10 minute, delete session
    $sql4 = "DELETE FROM active_users_online WHERE timestamp < $time_check";
    $result4=mysql_query($sql4, $connwmis) or die(mysql_error());

    mysql_close();

    // Open multiple browser page for result
    ?>
    ------------------------------------------------------------------

    Here is the code for Displaying active users at site:
    --------------------------------------------------
    <?php
    //open connection to the database
    require_once('inc_conn.php');
    // prepare query
    $sql="SELECT * FROM active_users_online";
    //execute sql statements
    $sessions = mysql_query($sql, $connwmis) or die(mysql_error());
    //retrieve one row of records
    $rows_sessions = mysql_fetch_array($sessions);
    //determine the number of records in recordset
    $num_rows = mysql_num_rows($sessions);
    ?>
    <?php
    require_once('inc_conn.php');
    $gap=10; // Gap value can be changed, this is in minutes.
    // let us find out the time before 10 minutes of present time. //
    $time=date ("Y-m-d H:i:s", mktime (date("H"),date("i")-$gap,date("s"),date("m"),date("d"),date("Y")));
    $ut=mysql_query("update active_users_online set status='OFF' where timestamp < '$time'");
    $ro = mysql_query("SELECT username,timestamp FROM active_users_online where timestamp > '$time' and status='ON'");
      $active = mysql_num_rows($ro); // sets $active as the number of active users
     
      echo "Logged users: <b>".$rows_sessions['username']."</b><br>"; // lists the username of active users
      echo "Last Logged: <b>".$rows_sessions['timestamp']."</b><br>"; // lists the number of active users

    ?>
    </td>
    </tr>
    <tr>
    <td><?php // Actually lists the users
      do {
    $name = $rows_sessions['username']; // Sets $name as the users' names
    $i= 0;
    // Lists the users names
    if ($i != ($num_rows - 1)) { // if $i doesn't equal $active minus 1
      echo "<b>".$name." | ";
    }
    else {
    echo "<b>".$name."</b>";
    }

    $i++; // increase temp variable
    } while ($rows_sessions = mysql_fetch_array($sessions)) ?></td>
    </tr>
    --------------------------------------------------

    Something is wrong, I dont know.
    Can somebody help me please????
  7. Hi All

    Please help me...

    I have a problem with this function : onclick='javascript: history.go(-1)' whenever I click the Back Button on my form. Here is the html code from my form.
    <td height="10" width="70">
    <input name="back" type="submit" value="Back" onclick='javascript: history.go(-1)' class="button">
    </td>
    When I click this button... I get this error:

    ---------------------
    Warning: Page has Expired The page you requested was created using information you submitted in a form. This page is no longer available. As a security precaution, Internet Explorer does not automatically resubmit your information for you.

    To resubmit your information and view this Web page, click the Refresh button.
    ---------------------

    Please help, what must I do? What is my problem? Whats strange is that, I've been using this back button for a while, but now its giving me this problem. for the past 2 days. I though it was the browser problem, but then I deleted the cookies and I reboot my machine but still there.

    Please help me?

    Thank you  >:(
  8. Hi All

    I wanted to have a SCRIPT that will determine who is online & logged into our system. I want to send that information to my db. I do have the script, but I do not know where to put the script.
    here is the script:
    ========================
    <?php session_start();
    $session=session_id();
    $time=time();
    $time_check=$time-600; //SET TIME 10 Minute

    //open connection to the database
    require_once('inc_conn.php');
    // prepare query
    $sql="SELECT * FROM user_online WHERE session = '".$session."'";
    //execute sql statements
    $sessions = mysql_query($sql, $connimgp) or die(mysql_error());
    //retrieve one row of records
    $rows_sessions = mysql_fetch_array($sessions);
    //determine the number of records in recordset
    $num_rows = mysql_num_rows($sessions);
    if($num_rows=="0"){
    $sql1="INSERT INTO user_online(session, time,username)VALUES('$session', '$time','$username')";
    $result1 = mysql_query($sql1, $connimgp) or die(mysql_error());
    }
    else {
    $sql2="UPDATE user_online SET time='$time' WHERE session = '$session'";
    $result2 = mysql_query($sql2, $connimgp) or die(mysql_error());
    }

    $sql3 = "SELECT * FROM  user_online";
    $result3 = mysql_query($sql3, $connimgp) or die(mysql_error());

    $count_user_online=mysql_num_rows($result3);



    // if over 10 minute, delete session
    $sql4 = "DELETE FROM user_online WHERE time < $time_check";
    $result4=mysql_query($sql4, $connimgp) or die(mysql_error());

    mysql_close();

    // Open multiple browser page for result
    ?>
    ====================================

    Is this the right script?
    Can somebody tell me where to put in my system?
    here is my login system
    login_verify.php:
    =========================
    <?php session_start(); ?>
    <?php
    // Test if the user clicked on the register button
    if(isset($_REQUEST['btnlogin'])){
    $username = strtolower(trim($_REQUEST['username']));
    $persalno = strtolower(trim($_REQUEST['persalno']));
    $password = strtolower(trim($_REQUEST['password']));

    // Connect to the MYSQL server and use dbaddbook
    require_once('inc_conn.php');

    // Check if the username exists in the database

    //$sql = "SELECT users.persalno, users.username, userrole.roleid FROM user, userrole WHERE users.username = '".$username."' AND users.password = password('".$password."') AND users.persalno = userrole.persalno";
    $sql = "SELECT users.persalno, users.username, userrole.roleid FROM users, userrole WHERE users.persalno = '".$persalno."' AND users.password = password('".$password."') AND users.persalno = userrole.persalno";

    // Create a recordset called  $rssignin
    $rssignin = mysql_query($sql, $connimgp);

    // Find out how many seconds are in the recordset and extract the first record from the recordset
    $row_rssignin = mysql_fetch_array($rssignin);

    // Now we have to check if the recordset returned any records
    if($row_rssignin > 0){
    // get records and set to session variables
    $_SESSION['svuid'] = $row_rssignin['persalno'];
    $_SESSION['svuname'] = $row_rssignin['username'];
    $_SESSION['svroleid'] = $row_rssignin['roleid'];


    // Free up the resultset
    mysql_free_result($rssignin);

    /**************************/
    // initialise return statement
    $returnaccess;

    // check that the user's role has been set before proceeding
    if(isset($_SESSION['svroleid'])){
    // Connect to the MYSQL server and use dbaddbook
    require_once('inc_conn.php');
    // prepare sql statement to axtract user's access level clearance and corresponding permissions for each level
    $sql = "SELECT levelid, permid FROM task, roletask WHERE task.taskid = roletask.taskid AND roletask.roleid = '".$_SESSION['svroleid']."'";

    $rstasks = mysql_query($sql, $connimgp) or die("There was an error : ".mysql_errno()." : ".mysql_error());

    $rows_rstasks = mysql_fetch_array($rstasks);

    if($rows_rstasks > 0){
    // prepare array for credentials
    $permarray = array();
    do{
    if($permarray[$rows_rstasks['levelid']]){
    //if point we are at corresponds to level id, add value at index [$rows_rstasks['levelid']][(count($permarray[1]))]
    $permarray[$rows_rstasks['levelid']][count($permarray[1])] = $rows_rstasks['permid'];
    } else { // if this level has not yet been created in array, create it and place value in it
    $permarray[$rows_rstasks['levelid']] = array($rows_rstasks['permid']);
    }
    }while($rows_rstasks = mysql_fetch_array($rstasks));
    }
    // free resultset
    mysql_free_result($rstasks);
    }
    $returnaccess = $permarray;
    $_SESSION['svcred'] = $returnaccess;
    /**************************/


    // Redirect the user back to the registration page if a duplicate username was found - append a parameter
    header("Location: index.php"); // somewhere
    // Prevents the rest of the code form executing
    break;
    } else {
    // Free up the resultset
    mysql_free_result($rssignin);

    // Redirect the user back to the registration page if a duplicate username was found - append a parameter
    header("Location: login.php?username=notexist");
    }
    // Close the connection
    mysql_close($connimgp);
    }
    ?>
    =========================

    Thank you
    9911782
  9. Its a system where users upload their workplan & budget documents to be seen by other co-users on the websites. Each user is responsible for uploading his workplan document file to the server, and can download it and update it as well. User can also send the remarks about his uploaded workplan. User can also able to edit/update his own workplan. Other user are not allowed to remark to other user's workplan, only the owner of the workplan can send the remarks about his workplan.

    Now, I have noticed that people can use other user's login details while the original user is on line. I only need 1 login for 1 login details per user. I want to prevent multiple logins using the same login details. This will help me to keep track of who have done the updates on the specific page or website.

    Can you help me now?
  10. Hi All
    I have started using PHP & MYSQL this year. I have done 2 application with the knowledge I get from the forums and trainings.

    I booked myself to the PHP Advanced course, they were training us on using the classes too. Can somebody help me to understand the classes more. I need to use the classes in my applications. Can I get the site where I could get the tutorial to learn more on how to create classes.

    Thank you :)
    9911782
  11. [quote author=ProjectFear link=topic=110216.msg445112#msg445112 date=1159783327]
    well there is no function RecordCount in any of those files, after my quick scanning. So it obviously hasnt been made, or it is in a different file. but the error means that it cant find the function RecordCount
    [/quote]

    Hi ProjectFear

    I have found this function in this file. Here is the code:
    ----------------------------------------
    //==============================================================================================
    // CLASS ADORecordSet_empty
    //==============================================================================================

    /**
    * Lightweight recordset when there are no records to be returned
    */
    class ADORecordSet_empty
    {
    var $dataProvider = 'empty';
    var $databaseType = false;
    var $EOF = true;
    var $_numOfRows = 0;
    var $fields = false;
    var $connection = false;
    function RowCount() {return 0;}
    function RecordCount() {return 0;} 
    function PO_RecordCount(){return 0;}
    function Close(){return true;}
    function FetchRow() {return false;}
    function FieldCount(){ return 0;}
    function Init() {}
    }

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