php脚本点击链接更新mysql表 [英] php script to update mysql table on click of link

查看:61
本文介绍了php脚本点击链接更新mysql表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是php的新手,需要帮助。

我无法下载文件和文件。同时更新数据库的日志表。

如需了解更多详情,请参阅链接。



而且,我的代码如下:

 < span class =code-pagedirective><?php  
$ DownDir = http:// localhost / SGA-INTRANET /。$ kmsroot。 /。 $用户。 /。 $蒲式耳。 /。 $客户端。 /。 $ project。 / Final;
$ filenames = file.xlsx ;

$ pathDown1 = $ DownDir。 /。$ filenames; // 下载路径

// 使用HTML 5的下载功能
echo ' < a download =Final_File _'。$ filenames。' name =保存href ='。$ pathDown1。' ?id ='。$ name 。' & filepath ='。$ pathDown1。' target =_ blank>< img src =images / Save File.pngtitle =下载文件/>< / a> ;
?>

<? php

$ ide = $ _GET [' id']; // EmployeeID
$ file = $ _GET [' filepath']; // 路径

if(isset($ ide)&& isset($ file ))
{
if(file_exists($ file))
{
// 将日志保存到数据库表'tbl_km_file_download'
$ mysqli = new mysqli( localhost USE RNAME PASSWORD DBNAME);
$ mysqli-> query( INSERT INTO`tbl_km_file_download`(`name`,`filename`) VALUES('$ ide','$ file'));
}
}

?>

解决方案

DownDir = http:// localhost / SGA-INTRANET /

kmsroot。 /


user。 /


I'm new to php and need help.
I'm not able download a file & update the DB's log table at the same time.
For more details please, please, please see the Link.

And, My code as below:

<?php
$DownDir = "http://localhost/SGA-INTRANET/".$kmsroot. "/". $user. "/". $bu. "/". $client. "/". $project."/Final";
$filenames = "file.xlsx";

$pathDown1 = $DownDir. "/".$filenames;//download path

//using download functionality of HTML 5
echo '<a download="Final_File_'.$filenames.'" name="save" href="'.$pathDown1.'?id='.$name.'&filepath='.$pathDown1.'" target="_blank"><img src="images/Save File.png" title="Download the file"/></a>';
?>

<?php 

$ide = $_GET['id'];//EmployeeID
$file = $_GET['filepath'];// Path

if(isset($ide) && isset($file)) 
{
 if(file_exists($file)) 
  {
    //save log to DB table 'tbl_km_file_download'
    $mysqli = new mysqli("localhost", "USERNAME", "PASSWORD", "DBNAME");
    $mysqli->query("INSERT INTO `tbl_km_file_download` (`name`, `filename`) VALUES ('$ide',  '$file')");
  }
}

?>

解决方案

DownDir = "http://localhost/SGA-INTRANET/".


kmsroot. "/".


user. "/".


这篇关于php脚本点击链接更新mysql表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆