-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathadminka.php
171 lines (163 loc) · 6.3 KB
/
adminka.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
<?php
error_reporting(E_ALL);
//error_reporting(0);
session_start();
date_default_timezone_set('Europe/Kiev');
$today = date("Y-m-d H:i:s");
include('connect.php');
include('translate.php');
$err = $nameErr = $nomerErr = $misceErr = $cycleErr = "";
$name = $nomer = $misce = $cycle = "";
function test_input($data) {
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
return $data;
}
?>
<html>
<header>
<meta charset="UTF-8">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous">
<style>
.error {color: #FF0000;}
#language {
text-align: right;
}
</style>
</header>
<body>
<body onload="setFocus()">
<div id="language">
<a href="en/index.php"><img src="en.jpg" alt="English" height="30" wieght="30">English</a>
<a href="index.php"><img src="ua.jpg" alt="Ukrainian" height="30" wieght="30">Ukrainian</a>
</div>
<br>
<?php
if (isset($_POST['subBtn'])){
if ($_SERVER["REQUEST_METHOD"] == "POST"){
if (empty($_POST["nomer"])) {
$nomerErr = $tr_err_nom;
} else {
$nomer = test_input($_POST["nomer"]);
// check if name only contains letters and whitespace
if (!preg_match("/^[0-9A-Z]*$/",$nomer)) {
$nomerErr = $tr_err_nom1;
}
}
if (empty($_POST["misce"])) {
$misceErr = $tr_err_misce;
} else {
$misce = test_input($_POST["misce"]);
// check if name only contains letters and whitespace
if (!preg_match("/^[a-zA-Z ]*$/",$misce)) {
$misceErr = $tr_err_misce1;
}
}
if (empty($_POST["cycle"])) {
$cycleErr = $tr_err_cycle;
} else {
$cycle = test_input($_POST["cycle"]);
// check if name only contains letters and whitespace
if (!preg_match("/^[0-9]*$/",$cycle)) {
$cycleErr = $tr_err_cycle1;
/*$sql = "SELECT `cycle` FROM `komax` WHERE 1" ;
$res = $mysqli->query($sql);
if ( $res >($_POST["cycle"])) {
$cycleErr = $tr_err_cycle1;
}*/
}
}
}
if (empty($nomerErr)){
if (empty($misceErr)){
if (empty($cycleErr)){
//if (isset($err)){
$id = $mysqli->insert_id;
$nomer = $_POST['nomer'];
$misce = $_POST['misce'];
$cycle = $_POST['cycle'];
$time = $today;
$sql = "INSERT INTO `komax` (`id`, `nomer`, `misce`, `cycle`, `time`) VALUES ('$id', '$nomer', '$misce', '$cycle', '$time')";
$sql1 = "INSERT INTO `komaxupd` (`id`, `nomer`, `misce`, `cycle`, `time`) VALUES ('$id', '$nomer', '$misce', '$cycle', '$time')";
// $sql = "update `komaxupd` SET `misce`='$misce', `cycle`='$cycle', `time`='$time' WHERE `nomer`='$nomer' ";
if ($mysqli->query($sql) === TRUE) {
$mysqli->query($sql1);
echo $tr_base_ok;
header('Location: index.php');
exit;
}
}
}
}
}
?>
<table border='0' cellpadding='0' cellspacing='0' style='width: 100%; height: 40px'><tbody><tr>
<td style='width: 75%; height: 10px'><a href="index.php"><img src="images.jpg" alt="Logo Fujikura"></a><B><h2><?php echo $tr_oblik;?></h2></td>
<td style='width: 25%; height: 10px'><B>
<a href='index.php'><input type="submit" name="add_newBtn" tabindex="6" value="<?php echo $tr_add_apl;?>"></a><br><br>
<a href='read.php'><input type="submit" name="readBtn" tabindex="7" value="<?php echo $tr_read;?>"></a><br><br>
<a href='read_all.php'><input type="submit" name="read_allBtn" tabindex="8" value="<?php echo $tr_read_all;?>"></a><br><br>
</td></tr>
<tr><td style='width: 75%; height: 10px'><B>
<form id="form_send" method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>">
<?php echo $tr_nomer;?><input type="text" id="inp_nomer" name="nomer" maxlength="5" tabindex="1" required>
<?php echo $tr_misce;?><input type="text" id="inp_misce" name="misce" maxlength="15" tabindex="2" required>
<?php echo $tr_cycle;?><input type="text" id="inp_cyсle" name="cycle" maxlength="9" tabindex="3" required>
<span class="inp_sub"><input type="submit" id="inp_btn" name="subBtn" tabindex="5" value="<?php echo $tr_add_new;?>"></span>
<br>
<span class="error"><?php echo $nomerErr;?></span><br>
<span class="error"><?php echo $misceErr;?></span><br>
<span class="error"><?php echo $cycleErr;?></span><br>
<br>
</form></td>
<td style='width: 25%; height: 10px'><B> </td></tr></tbody></table>
<script src="//code.jquery.com/jquery-3.1.1.min.js" integrity="sha256-hVVnYaiADRTO2PzUGmuLJr8BLUSjGIZsDYGmIJLv2b8=" crossorigin="anonymous"></script>
<script src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
<script type="text/javascript">
/* global $*/
function myFunction() {
document.getElementById("form_send").submit();
}
function setFocus(){
{
document.getElementById("inp_nomer").focus();
$("#inp_nomer").keyup(function(event){
if(event.keyCode == 13){
document.getElementById("inp_misce").focus();
event.preventDefault();
}
});
$("#inp_misce").keyup(function(event){
if(event.keyCode == 13){
document.getElementById("inp_cycle").focus();
event.preventDefault();
}
});
$("#inp_cycle").keyup(function(event){
if(event.keyCode == 13){
document.getElementById("form_send").submit();
//document.span.innerHTML ="<h1>Text in html</h1>";
//document.getElementById("form_send").submit(); return false;
//document.getElementById("inp_btn").html.;
//document.getElementById("myForm").submit();
//$("#inp_btn").onclick("#submit_form");
event.preventDefault();
}
});
// $("#inp_btn").keyup(function(event){
// if(event.keyCode == 13){
// document.getElementById("inp_btn").submit();
// event.preventDefault();
// }
// });
}
return false;
}
</script>
<script type="javascript" >
</script>
<?php //include('copyright.php');?>
</body>
</html>