修改公司数据 - 数据安全平台
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>修改数据</title>
</head>
<body background="../../images/DNA1.jpg">
<style>
.aa {
font-family: 楷体;
font-size: 2.5rem;
position: absolute;
top: 50px;
left: 250px;
background: transparent;
text-shadow: 0 0 4px rgb(155, 116, 116),
0 0 4px rgb(155, 116, 116),
0 0 4px rgb(155, 116, 116);
}
<pre><code> .ab {
font-family: 楷体;
font-size: 2.5rem;
position: absolute;
top: 50px;
left: 250px;
background: transparent;
text-shadow: 0 0 4px rgb(155, 116, 116),
0 0 4px rgb(155, 116, 116),
0 0 4px rgb(155, 116, 116);
}
.zong{
display:flex;
width:100%;
height:500px;
}
.ac {
display: flex;
flex-direction: row;
width: 450px;
height: 500px;
margin-top: 100px;
margin-left: 100px;
border: 3px solid rgb(149, 108, 108);
border-radius: 50px;
background-color: rgb(211, 208, 206);
justify-content: center;
align-items: center;
}
.ad {
width: 700px;
height: 500px;
margin-top: 100px;
margin-left: 50px;
border: 3px solid rgb(149, 108, 108);
border-radius: 50px;
background-color: rgb(211, 208, 206);
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}
.abc {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
font-size: 1.5rem;
font-family: 楷体;
margin-top: 5px;
}
.query-menu {
width: 400px;
height: 40px;
margin-bottom: 25px;
margin-left: 30px;
align-self: flex-start;
}
.modify-data input {
width: 400px;
height: 40px;
margin-bottom: 25px;
margin-left: 30px;
}
.normal-button {
width: 200px;
height: 50px;
border-radius: 30px;
background-color: rgb(97, 151, 97);
text-align: center;
margin-top: 25px;
margin-left: 30px;
}
</style>
<div class="zong">
<div class="ac">
<div class="aa">修改数据</div>
<div class="abc">
<form action="modify-table2.php" method="post" id="query-num-form">
<h3>修改数据</h3>
<select name="query-menu" class="query-menu">
<option value="Organization_type">公司类型</option>
<option value="Entity">公司名</option>
</select>
<div class="modify-data">
修改数据的编号/公司名:
<input type="text" name="input1" placeholder="请输入...">
</div>
<div class="modify-data">
修改为:
<input type="text" name="input2" placeholder="请输入...">
</div>
<button type="submit" class="normal-button">提交</button>
<button type="button" onclick="window.location.href = '../index.php'" style="width:150px;height:50px;border-radius: 30px;background-color: rgb(97, 151, 97);text-align: center;margin-top: 5px;">返回上一个页面</button>
</form>
</div>
</div>
<div class="ad">
<?php
//including the Mysql connect parameters.
$link = mysqli_connect("localhost", "admin", "admin", "data_breach");
if (!$link) {
die("连接失败: " . mysqli_connect_error());
}
if (isset($_POST['query-menu']) && isset($_POST['input1'])) {
$name = $_POST['query-menu'];
$Entity= mysqli_real_escape_string($link, $_POST['input1']);
$value_new = mysqli_real_escape_string($link, $_POST['input2']);
// 关闭自动提交
mysqli_autocommit($link, FALSE);
// 获取表名
$table_sname_query = "SELECT table_sname FROM connection WHERE columns_sname='$name'" ;
$table_sname_result = mysqli_query($link, $table_sname_query);
$table_sname_row = mysqli_fetch_assoc($table_sname_result);//将查询结果返回到数组中
$table_sname = $table_sname_row['table_sname'];//只获取table_name
if($name=="Year" or $name=="Records"){
$value_new=(int)$value;
$delete_query = "UPDATE company SET $name=$value_new WHERE Entity=$Entity";
$result = mysqli_query($link, $delete_query);
}else{
$delete_query = "UPDATE company SET $name=$value_new WHERE Entity='$Entity'";
$result = mysqli_query($link, $delete_query);
}
if ($result && mysqli_affected_rows($link) == 1) {
mysqli_commit($link);
//mysqli_close($link);
echo "<script>window.location.href = 'index.php';</script>";
} else {
echo $result;
//echo mysqli_affected_rows($link);
mysqli_rollback($link);
mysqli_close($link);
echo 'false';
echo gettype($value);
echo $value;
}
} else {
}
// 获取表中数据 这里是自动提交
$select_query = "SELECT * FROM company order by Entity desc limit 10";
$select_result = mysqli_query($link, $select_query);
$data = array();
while ($row = mysqli_fetch_assoc($select_result)) {
$data[] = $row;
}
echo '<table>';
// 输出表头
echo '<tr>';
foreach ($data[0] as $key => $value) {
echo '<th>' . $key . '</th>';
}
echo '</tr>';
// 输出数据行
foreach ($data as $row) {
echo '<tr>';
foreach ($row as $value) {
echo '<td>' . $value . '</td>';
}
echo '</tr>';
}
echo '</table>';
mysqli_close($link);
?>
</div>
</div>
</div>
</code></pre>
</body>
</html>
原文地址: https://www.cveoy.top/t/topic/oAWS 著作权归作者所有。请勿转载和采集!