patk570 42 Newbie Poster

I have a url that is

filemgr.php

when a user navigates to lower levels of said file manager it shows up as

filemgr.php#userfiles/username/Images

Is there a way to just have it show up as

filemgr.php

with out the rest of the url showing?

I am open to .htaccess editing and php code.

patk570 42 Newbie Poster
patk570 42 Newbie Poster

set a database field called metadescription then on page load do something like

<meta name="description" content="<?php echo $metadescription ?>">

then it will echo the description of each post when you call for it based on ID of post or how ever you have it generate...

patk570 42 Newbie Poster

I got the toplevel to show my username folder. But when i click on it it does not show the next levels. Here is my updated code.

<?php
/********************************
Simple PHP File Manager
Copyright John Campbell (jcampbell1)

Liscense: MIT
********************************/
// must be in UTF-8 or `basename` doesn't work
setlocale(LC_ALL,'en_US.UTF-8');

$tmp = realpath($_REQUEST['file']);
if($tmp === false)
err(404,'File or Directory Not Found');
if(substr($tmp, 0,strlen(__DIR__)) !== __DIR__)
err(403,"Forbidden");

if(!$_COOKIE['_sfm_xsrf'])
setcookie('_sfm_xsrf',bin2hex(openssl_random_pseudo_bytes(16)));
if($_POST) {
if($_COOKIE['_sfm_xsrf'] !== $_POST['xsrf'] || !$_POST['xsrf'])
err(403,"XSRF Failure");
}
/*$_REQUEST['file'] ?: '.';*/
$file = './userfiles/'.htmlentities(ucwords($_SESSION['username'])); //Added this section to be the top level
if($_GET['do'] == 'list') {
if (is_dir($file)) {
$directory = $file;
$result = array();
$files = array_diff(scandir($directory), array('.','..'));
foreach($files as $entry) if($entry !== basename(__FILE__)) {
     $i = $directory . '/' . $entry;
$stat = stat($i);
$result[] = array(
'mtime' => $stat['mtime'],
'size' => $stat['size'],
'name' => basename($i),
'path' => preg_replace('@^\./@', '', $i),
'is_dir' => is_dir($i),
'is_deleteable' => (!is_dir($i) && is_writable($directory)) ||
(is_dir($i) && is_writable($directory) && is_recursively_deleteable($i)),
'is_readable' => is_readable($i),
'is_writable' => is_writable($i),
'is_executable' => is_executable($i),
);
}
} else {
err(412,"Not a Directory");
}
echo json_encode(array('success' => true, 'is_writable' => is_writable($file), 'results' =>$result));
exit;
} elseif ($_POST['do'] == 'delete') {
rmrf($file);
exit;
} elseif ($_POST['do'] == 'mkdir') {
chdir($file);
@mkdir($_POST['name']);
exit;
} elseif ($_POST['do'] == 'upload') {
var_dump($_POST);
var_dump($_FILES);
var_dump($_FILES['file_data']['tmp_name']);
var_dump(move_uploaded_file($_FILES['file_data']['tmp_name'], $file.'/'.$_FILES['file_data']['name']));
exit;
} elseif ($_GET['do'] == 'download') {
$filename = basename($file);
header('Content-Type: ' . mime_content_type($file));
header('Content-Length: '. filesize($file));
header(sprintf('Content-Disposition: attachment; filename=%s',
strpos('MSIE',$_SERVER['HTTP_REFERER']) ? rawurlencode($filename) : "\"$filename\"" ));
ob_flush();
readfile($file);
exit;
}
function rmrf($dir) {
if(is_dir($dir)) {
$files …
patk570 42 Newbie Poster

I did find this one, I do like it, I need to know how to target the username path as the top level.

<?php
/********************************
Simple PHP File Manager
Copyright John Campbell (jcampbell1)

Liscense: MIT
********************************/

/* Uncomment section below, if you want a trivial password protection */

/*
$PASSWORD = 'sfm';
session_start();
if(!$_SESSION['_sfm_allowed']) {
// sha1, and random bytes to thwart timing attacks. Not meant as secure hashing.
$t = bin2hex(openssl_random_pseudo_bytes(10));
if($_POST['p'] && sha1($t.$_POST['p']) === sha1($t.$PASSWORD)) {
$_SESSION['_sfm_allowed'] = true;
header('Location: ?');
}
echo '<html><body><form action=? method=post>PASSWORD:<input type=password name=p /></form></body></html>';
exit;
}
*/

// must be in UTF-8 or `basename` doesn't work
setlocale(LC_ALL,'en_US.UTF-8');

$tmp = realpath($_REQUEST['file']);
if($tmp === false)
err(404,'File or Directory Not Found');
if(substr($tmp, 0,strlen(__DIR__)) !== __DIR__)
err(403,"Forbidden");

if(!$_COOKIE['_sfm_xsrf'])
setcookie('_sfm_xsrf',bin2hex(openssl_random_pseudo_bytes(16)));
if($_POST) {
if($_COOKIE['_sfm_xsrf'] !== $_POST['xsrf'] || !$_POST['xsrf'])
err(403,"XSRF Failure");
}

$file = $_REQUEST['file'] ?: '.';
if($_GET['do'] == 'list') {
if (is_dir($file)) {
$directory = $file;
$result = array();
$files = array_diff(scandir($directory), array('.','..'));
foreach($files as $entry) if($entry !== basename(__FILE__)) {
     $i = $directory . '/' . $entry;
$stat = stat($i);
$result[] = array(
'mtime' => $stat['mtime'],
'size' => $stat['size'],
'name' => basename($i),
'path' => preg_replace('@^\./@', '', $i),
'is_dir' => is_dir($i),
'is_deleteable' => (!is_dir($i) && is_writable($directory)) ||
(is_dir($i) && is_writable($directory) && is_recursively_deleteable($i)),
'is_readable' => is_readable($i),
'is_writable' => is_writable($i),
'is_executable' => is_executable($i),
);
}
} else {
err(412,"Not a Directory");
}
echo json_encode(array('success' => true, 'is_writable' => is_writable($file), 'results' =>$result));
exit;
} elseif ($_POST['do'] == 'delete') {
rmrf($file);
exit;
} elseif ($_POST['do'] == 'mkdir') {
chdir($file);
@mkdir($_POST['name']);
exit;
} elseif …
patk570 42 Newbie Poster

Hey Guys,

I am looking for a file manager that will allow me to customize the top level folder( to the user that is logged in) as the top level.

The folder structure should be something like

   username
       Folder 1
           Sub folder 1.1
           Sub folder 1.2

       Folder 2
           Sub Folder 2.1
           Sub Folder 2.2
      ETC..

Is there
A) a free one/opensouce one i can use use
or
B) a simple way to make one to where they can upload/delete/edit

Thanks!

patk570 42 Newbie Poster

Use placeholder tag, its easier...

<input id="text" type="text" name="fname" placeholder='First Name"/>
patk570 42 Newbie Poster
patk570 42 Newbie Poster

I have 2 input fields that when a user inputs the date in say mm-dd-yyyy format, i would like to have it automatically change to yyyy-mm-dd (ISO 8601 Date Format)

the input fields are very simple:

<div class="form-group">
        <label for="purchase_date">Purchase Date <font size="-3">(Year-MM-DD) format</font></label>
        <input type="text" name="purchase_date" class="form-control"  placeholder="Purchase Date">
</div>
<div class="form-group">
        <label for="warranty_end_date">Warranty End Date <font size="-3">(Year-MM-DD) format</font></label>
        <input type="text" name="warranty_end_date" class="form-control"  placeholder="Warranty End Date">
</div>

is there a way to do this without using datepicker? I dont want to add any extra styling sheets or any extra js..

patk570 42 Newbie Poster

I know, That is why i am asking where the proper placement is for the validation, Currently its under the login script after its successful. But I am also not sure if it is actually validating becuase i cannot see anything being return.

patk570 42 Newbie Poster

and at the top of my page i have: include_once 'validateKey.php';

patk570 42 Newbie Poster

Im unsure where to put the variable to validate the license, here is what i have so far,

function login($email, $password, $mysqli) {
    // Using prepared statements means that SQL injection is not possible. 
    if ($stmt = $mysqli->prepare("SELECT id, username, password, salt, license_key 
        FROM members
       WHERE email = ?
        LIMIT 1")) {
        $stmt->bind_param('s', $email);  // Bind "$email" to parameter.
        $stmt->execute();    // Execute the prepared query.
        $stmt->store_result();

        // get variables from result.
        $stmt->bind_result($user_id, $username, $db_password, $salt, $licensekey);
        $stmt->fetch();

        // hash the password with the unique salt.
        $password = hash('sha512', $password . $salt);
        if ($stmt->num_rows == 1) {
            // If the user exists we check if the account is locked
            // from too many login attempts 

            if (checkbrute($user_id, $mysqli) == true) {
                // Account is locked 
                // Send an email to user saying their account is locked
                return false;
            } else {
                // Check if the password in the database matches
                // the password the user submitted.
                if ($db_password == $password) {
                    // Password is correct!
                    // Get the user-agent string of the user.
                    $user_browser = $_SERVER['HTTP_USER_AGENT'];
                    // XSS protection as we might print this value
                    $user_id = preg_replace("/[^0-9]+/", "", $user_id);
                    $_SESSION['user_id'] = $user_id;
                    // XSS protection as we might print this value
                    $username = preg_replace("/[^a-zA-Z0-9_\-]+/", 
                                                                "", 
                                                                $username);
                    $_SESSION['username'] = $username;
                    $_SESSION['login_string'] = hash('sha512', 
                              $password . $user_browser);
                    // Login successful.
                    check_license($licensekey) ;
                    return true;


                } else {
                    // Password is not correct
                    // We record this attempt in the database
                    $now = time();
                    $mysqli->query("INSERT INTO login_attempts(user_id, time)
                                    VALUES ('$user_id', '$now')");
                    return false; …
patk570 42 Newbie Poster

Hello, I am working on some code that does a remote call to a licensing server to validate whether the license is valid, invalid, expired and suspended.

I have a login code that is using prepared statements:

function login($email, $password, $mysqli) {
    // Using prepared statements means that SQL injection is not possible. 
    if ($stmt = $mysqli->prepare("SELECT id, username, password, salt 
        FROM members
       WHERE email = ?
        LIMIT 1")) {
        $stmt->bind_param('s', $email);  // Bind "$email" to parameter.
        $stmt->execute();    // Execute the prepared query.
        $stmt->store_result();

        // get variables from result.
        $stmt->bind_result($user_id, $username, $db_password, $salt);
        $stmt->fetch();

        // hash the password with the unique salt.
        $password = hash('sha512', $password . $salt);
        if ($stmt->num_rows == 1) {
            // If the user exists we check if the account is locked
            // from too many login attempts 

            if (checkbrute($user_id, $mysqli) == true) {
                // Account is locked 
                // Send an email to user saying their account is locked
                return false;
            } else {
                // Check if the password in the database matches
                // the password the user submitted.
                if ($db_password == $password) {
                    // Password is correct!
                    // Get the user-agent string of the user.
                    $user_browser = $_SERVER['HTTP_USER_AGENT'];
                    // XSS protection as we might print this value
                    $user_id = preg_replace("/[^0-9]+/", "", $user_id);
                    $_SESSION['user_id'] = $user_id;
                    // XSS protection as we might print this value
                    $username = preg_replace("/[^a-zA-Z0-9_\-]+/", 
                                                                "", 
                                                                $username);
                    $_SESSION['username'] = $username;
                    $_SESSION['login_string'] = hash('sha512', 
                              $password . $user_browser);
                    // Login successful.
                    return true;
                } else {
                    // Password is not correct
                    // We record this attempt …
patk570 42 Newbie Poster

Please use the </>Code button to paste code, please resubmit it...

patk570 42 Newbie Poster

try this:

#rightside .paypal{height:15px; width:45px;}

then add the class to the form of class='paypal'

patk570 42 Newbie Poster
patk570 42 Newbie Poster

there is no session set, so it is going to return false.

<?php 
    include('file_that_contains_connect_and_registers_cookie);
    session_start();
?>
patk570 42 Newbie Poster

post code for button?

patk570 42 Newbie Poster

Your looking for a table called parts, yet you are querying a table named users?

patk570 42 Newbie Poster

I have a code that i want to throw an error if there is no items to delete or if there is items it proceeds with deleting the items, here is what i have so far:

    if (isset($_REQUEST['removeall'])){
            if($_REQUEST['removeall'] == 1){
        mysqli_query($mysqli,"DELETE FROM assets WHERE cust_id = $custID AND del_flag = 1 ");
        if(mysqli_query < 1){
            $result = '<div class="alert alert-warning alert-dismissable"><button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>No assets to delete</div>';
        }
        $result = '<div class="alert alert-success alert-dismissable"><button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>All Assets Deleted</div>';

            }
    }

Am i on the right track? Everytime i request it, it just says All Assets Deleted even though there are no assets flagged.

patk570 42 Newbie Poster

This might not be much, but you seem to have the ul, li tags defined twice in your css. What order do you have the css link scripts in?

on your template_css.css file try and comment out this:

ul {
margin : 2px;
padding : 0px;
list-style : none;
}
li {
line-height : 15px; /* tarpas tarp eiluciu */
padding-left : 20px;
padding-top : 0px;
background-image : url(images/arrow3.png);
background-repeat : no-repeat;
background-position : 0px 3px;
}

and see what happens.

patk570 42 Newbie Poster

I just looked at it on my side, and its working like you want, here is a screenshot

egsonas commented: Hmmm.... Starnge. have you any changes to code or just putted codes in separate files? +1
patk570 42 Newbie Poster

In your mysqli statement, you have $config defined right? if not, put at the top of your statement, $config ==""; then try again. But you are using it to show the sitename of your site, so it is obviously being used to return a row from the database.

patk570 42 Newbie Poster

Try this:

<!DOCTYPE HTML>
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>Toggle images</title>
    <style>
      .hidden{display:none;}
    </style>
  </head>

  <body>
         <ul>
    <li><a href="" id="6seat">6 Seater</a></li>
    <li><a href="" id="8seat">8 Seater</a></li>
    <li><a href="" id="10seat">10 Seater</a></li>
    </ul>
    <div id="imgdiv"></div>
    <!--Load JS at end for fast load times -->
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
    <script>
    $('#6seat').click(function() {
        $("img").remove()
$("#imgdiv").append("<img id='theImg' src='http://www.mytabletbooksqa.com/ProductImages/test1.gif'/>");

});
    $('#8seat').click(function() {
        $("img").remove()
$("#imgdiv").prepend("<img id='theImg' src='http://blogs.edweek.org/teachers/coach_gs_teaching_tips/Teaching%20To%20The%20Test.gif'/>");

});
    $('#10seat').click(function() {
        $("img").remove()
$("#imgdiv").append("<img id='theImg' src='http://csunplugged.org/sites/default/files/cartoons/turing%20test.jpg?1246936875'/>");

});
    </script>
  </body>
</html>
patk570 42 Newbie Poster
patk570 42 Newbie Poster

got it resolved:

<div class="socialfb">
    <a href="#" target="_blank"><img id="fbimg" src="./img/icons/facebook.png"></a>
</div>
<div class="socialtw">
    <a href="#" target="_blank"><img id="twimg" src="./img/icons/twitter.png"></a>
</div>

 .socialfb {
    top:51px;
    right:100px;
    height:30;
    width:30;
    background-repeat:no-repeat;
    position:fixed;
    z-index: -1;
}
.socialtw {
    top:51px;
    right:50px;
    height:30;
    width:30;
    background-repeat:no-repeat;
    position:fixed;
    z-index: -1;
}
patk570 42 Newbie Poster

Here is what i have tried so far jsfiddle

patk570 42 Newbie Poster

Here is what i have tried so far jsfiddle

patk570 42 Newbie Poster

Hey everyone, I have navbar from boostrap, I am trying to get the flags to append to the bottom/hang from the bottom of the nav on right side. Link to the site. The flags are just basic but i need to set the css style to "hang" from the navbar under the contact us section. Is there any way of doing this?

Thanks

patk570 42 Newbie Poster

I fixed it!

$(function() {
var tabCarousel = setInterval(function() {
        var tabs = $('#tab-carousel .nav-pills > li'),
            active = tabs.filter('.active'),
            next = active.next('li'),
            toClick = next.length ? next.find('a') : tabs.eq(0).find('a');

        toClick.trigger('click');
    }, 5000);
    //start on hover function
$('#tab-carousel > div ').hover(
                function(){
                    window.clearInterval(tabCarousel)
                },
                function(){
                    tabCarousel = setInterval(function() {
        var tabs = $('#tab-carousel .nav-pills > li'),
            active = tabs.filter('.active'),
            next = active.next('li'),
            toClick = next.length ? next.find('a') : tabs.eq(0).find('a');

        toClick.trigger('click');
    }, 5000);
                }
                );
});//end function
patk570 42 Newbie Poster

Ok, so i got it to stop(clear the interVal) but now on mouseout i need it to start back up. I tried this:

$(function() {
var tabCarousel = setInterval(function() {
    var tabs = $('#tab-carousel .nav-tabs > li'),
        active = tabs.filter('.active'),
        next = active.next('li'),
        toClick = next.length ? next.find('a') : tabs.eq(0).find('a');

    toClick.trigger('click');
}, 5000);
//start on hover function
$('#tab-carousel > div').hover(function(){
            window.clearInterval(tabCarousel);
$('#tab-carousel > div').mouseout(function(){
            window.setInterval(tabCarousel,5000);
            });//end hover
    });
});//end function
patk570 42 Newbie Poster

here is what i tried:

$('#tab-carousel').mouseover(function(){

                              clearInterval(tabCarousel);
                              alert('timer stopped');
                              },
                              function(){
                                  timer = setInterval( tabCarousel, 5000);
                                  alert('timer started');
                              });
patk570 42 Newbie Poster

here is a working example of it..I still cannot get the event to stop on mouseover...Click Here

patk570 42 Newbie Poster

Hey guys, I have a script that switches between tabs..It works perfectly, but what i am needing is a way for the script to stop when I have my mouse on the tab or content for the tab. I am using bootstrap and here is my fiddle with the working tab switch.

patk570 42 Newbie Poster

The key is going to have dashes, and 20 characters long.

12345-67890-15975-14

if(!regkey.length == 20(plus dashes?) {
 alert(This key is not the required length);
}

Like that?

patk570 42 Newbie Poster

Hello everyone, I am trying to get a code that will check the length of the a 'key' that will be generated in xxxxx-xxxxx-xxxxx-xx format. I need it to verify that it meets the requirements. I do not need it to validate on the server, but i do need it for my registration page. I have been looking at the web for examples, but the best i can see is using the $("#formname").validate(); but need it for just the kkey section.

Any help would be great! Thanks

patk570 42 Newbie Poster

Fixed it, I forgot to encapsulate the desc in desc such an idiot sometimes...

patk570 42 Newbie Poster

I am not sure why this is not working, Its setting the flags perfectly but will not update events...

            if(isset($_REQUEST['del'])){
                            if($_REQUEST['del'] == 1){
                            $asset_id = $_REQUEST['assetID'];
            $sql = "UPDATE assets, events SET assets.del_flag=1 , events.del_flag=1
WHERE assets.id='$asset_id' AND events.asset_id='$asset_id'" or die(mysqli_error($mysqli));
if ( $mysqli->query($sql) ) {
      $addevent1 = "INSERT INTO events(title, desc, event_date, cust_id, asset_id) VALUES ('$asset_tag', 'Flagged an asset for Deletion', '$adddate', '$custID', '$id')" or die(mysqli_error($mysqli));
                $mysqli->query($addevent1);   
            $result = '<div class="alert alert-danger">Item Deleted</div>';
            }
              }
            }

do you see anything wrong?

patk570 42 Newbie Poster

I solved this. THis is what i did:

$(document).ready(function() {
    $('.bottomMenu').fadeOut();

$(window).scroll(function () { 
    if ($(window).scrollTop() > 200) {
      $('#nav_bar').addClass('navbar-fixed-top');
      $('.bottomMenu').fadeIn();
    }

if ($(window).scrollTop() < 201) {
      $('#nav_bar').removeClass('navbar-fixed-top');
      $('.bottomMenu').fadeOut();
    }
  });
});

Works great!

patk570 42 Newbie Poster

Hi everyone,

I am working on a site, just one page with all the information on it. What happens now is when I scroll down the page, and I get past the navbar, it gets fixed to the top like I want. Its all working fine, but my question is, I have a table just below and when I scroll down, I want the links from the table to go into the nav bar using (hopefully) jquery to append the links to the nav and then have them highlight(scrollspy) as I get to the content that I am on. Here is a link to the site.. I havn't tried anything yet, I am looking for advise on how(if) this is possible!

Thanks

patk570 42 Newbie Poster

all you need to do is create a php/html form then wien submitting the form details, have it send to the mobile number instead. It will come as a message from the website with all the details.

patk570 42 Newbie Poster

I figured it out:

$purchase_date = mysqli_real_escape_string($mysqli, date('Y-m-d', strtotime(str_replace('-','/',$_POST['purchase_date']));
$warranty_end_date = mysqli_real_escape_string($mysqli, date('Y-m-d', strtotime(str_replace('-','/',$_POST['warranty_end_date']));

worked, just forgot to upload it to the server. I thought it was uploaded haha!!!

patk570 42 Newbie Poster

Hi, I have 2 fields that are used for date. In my fucntion, i have it format the date into Y-m-d format,

$purchase_date = mysqli_real_escape_string($mysqli,date('Y-m-d',$_POST['purchase_date']));
$warranty_end_date = mysqli_real_escape_string($mysqli,date('Y-m-d',$_POST['warranty_end_date']));

But when I enter a date into it, it just puts 0000-00-00

I thought this was the correct format, but seems to not work.

I did try this as well:

$purchase_date = mysqli_real_escape_string($mysqli, date('Y-m-d', strtotime(str_replace('-','/',$_POST['purchase_date']));
$warranty_end_date = mysqli_real_escape_string($mysqli, date('Y-m-d', strtotime(str_replace('-','/',$_POST['warranty_end_date']));

but didnt work either.

Here is the form elements as well:

<div class="form-group">
    <label for="purchase_date">Purchase Date</label>
    <input type="text" name="purchase_date" class="form-control" id="purchase_date" placeholder="Purchase Date">
</div>
<div class="form-group">
    <label for="warranty_end_date">Warranty End Date</label>
    <input type="text" name="warranty_end_date" class="form-control" id="warranty_end_date" placeholder="Warranty End Date">
</div>
patk570 42 Newbie Poster

I am using boostrap right now for my website, Great for mobile friendly!

patk570 42 Newbie Poster

I got it!!! here is what i did:

if(isset($_POST['AddHardwareAsset'])){
            $asset_tag = mysqli_real_escape_string($mysqli,$_POST['assetTag']);
            $serial_number = mysqli_real_escape_string($mysqli,$_POST['serialNumber']);
            $vendor = mysqli_real_escape_string($mysqli,$_POST['vendor']);
            $platform = mysqli_real_escape_string($mysqli,$_POST['platform']);
            $type = mysqli_real_escape_string($mysqli,$_POST['type']);
            $model = mysqli_real_escape_string($mysqli,$_POST['model']);
            $status = mysqli_real_escape_string($mysqli,$_POST['status']);
            $location = mysqli_real_escape_string($mysqli,$_POST['location']);
            $user = mysqli_real_escape_string($mysqli,$_POST['user']);
            $user_name = mysqli_real_escape_string($mysqli,$_POST['user_name']);
            $purchase_date = mysqli_real_escape_string($mysqli,$_POST['purchase_date']);
            $warranty_end_date = mysqli_real_escape_string($mysqli,$_POST['warranty_end_date']);
            $item_address = mysqli_real_escape_string($mysqli,$_POST['item_address']);
            $user_phone_number = mysqli_real_escape_string($mysqli,$_POST['user_phone_number']);
            $comments = mysqli_real_escape_string($mysqli,$_POST['comments']);
            $repair_history = mysqli_real_escape_string($mysqli,$_POST['repair_history']);
            $product_key = mysqli_real_escape_string($mysqli,$_POST['product_key']);

            $hardquery = "INSERT INTO assets (cust_id, asset_tag, serial_number, vendor, platform, type, model, status, location, user, user_account, purchase_date, warranty_date, item_address, phone_number, comments, repair_history, product_key,asset_type) 
VALUES ('$custID','$asset_tag','$serial_number','$vendor','$platform','$type','$model','$status','$location','$user','$user_name','$purchase_date','$warranty_end_date','$item_address','$user_phone_number','$comments','$repair_history','$product_key','hardware')";
        if ( $mysqli->query($hardquery) ) {

    $id = $mysqli->insert_id;

$addevent = "INSERT INTO events(title, event_date, cust_id, asset_id) VALUES ('$type', '$adddate', '$custID', '$id')";
$mysqli->query($addevent);

    $result =  '<div class="alert alert-success">'.$asset_tag.' has been added</div>';
} else {
    $result = '<div class="alert alert-danger">Item not added.</div>';
}
        }
patk570 42 Newbie Poster

Hello, thanks for the reply, I did try that, and everytime I would enter it, it would just put a 0 in the events table.

patk570 42 Newbie Poster

Hi guys, I am trying to get the last_insert_id() from the table above, that way when it sends the query and is successful, it then updates the events table with timestamp, id , asset type and asset id from the insert code. I am currently using the max(id) but its not working, I want to make this easy and work perfectly. Any ideas what I can do differnt?

Thanks.

if(isset($_POST['AddHardwareAsset'])){
            $asset_tag = mysqli_real_escape_string($mysqli,$_POST['assetTag']);
            $serial_number = mysqli_real_escape_string($mysqli,$_POST['serialNumber']);
            $vendor = mysqli_real_escape_string($mysqli,$_POST['vendor']);
            $platform = mysqli_real_escape_string($mysqli,$_POST['platform']);
            $type = mysqli_real_escape_string($mysqli,$_POST['type']);
            $model = mysqli_real_escape_string($mysqli,$_POST['model']);
            $status = mysqli_real_escape_string($mysqli,$_POST['status']);
            $location = mysqli_real_escape_string($mysqli,$_POST['location']);
            $user = mysqli_real_escape_string($mysqli,$_POST['user']);
            $user_name = mysqli_real_escape_string($mysqli,$_POST['user_name']);
            $purchase_date = mysqli_real_escape_string($mysqli,$_POST['purchase_date']);
            $warranty_end_date = mysqli_real_escape_string($mysqli,$_POST['warranty_end_date']);
            $item_address = mysqli_real_escape_string($mysqli,$_POST['item_address']);
            $user_phone_number = mysqli_real_escape_string($mysqli,$_POST['user_phone_number']);
            $comments = mysqli_real_escape_string($mysqli,$_POST['comments']);
            $repair_history = mysqli_real_escape_string($mysqli,$_POST['repair_history']);
            $product_key = mysqli_real_escape_string($mysqli,$_POST['product_key']);

            $hardquery = "INSERT INTO assets (cust_id, asset_tag, serial_number, vendor, platform, type, model, status, location, user, user_account, purchase_date, warranty_date, item_address, phone_number, comments, repair_history, product_key,asset_type) 
VALUES ('$custID','$asset_tag','$serial_number','$vendor','$platform','$type','$model','$status','$location','$user','$user_name','$purchase_date','$warranty_end_date','$item_address','$user_phone_number','$comments','$repair_history','$product_key','hardware')";

    $query = "SELECT max(id) FROM assets ORDER by id DESC LIMIT 1";
    if ($result = $mysqli->query($query)) {
        /* fetch associative array */
     $row = $result->fetch_assoc();
     $insertid = $row["id"];
}
        if ( $mysqli->query($hardquery) ) {

            $addevent = "INSERT INTO events(title, event_date, cust_id, asset_id) VALUES ('$type', '$adddate', '$custID', '$insertid')";
                $mysqli->query($addevent);

    $result =  '<div class="alert alert-success">'.$asset_tag.' has been added</div>';
} else {
    $result = '<div class="alert alert-danger">Item not added.</div>';
}
        }
patk570 42 Newbie Poster

He can also just set the max height then have a scroll bar to show more..

.someclass{
height:250px;
overflow:auto;
}
patk570 42 Newbie Poster

To have the divs have different height, set your css to

.someclass{
    height:auto;
}
patk570 42 Newbie Poster

What have you tried so far? Plus we would need database structure, information about what needs to be inserted, deleted and edited...