-
Notifications
You must be signed in to change notification settings - Fork 0
/
cust_companiesUpdate.php
106 lines (89 loc) · 2.64 KB
/
cust_companiesUpdate.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
<!DOCTYPE html>
<html>
<body>
<?php
session_start();
require "menu.php";
require 'connectToDB.php';
$id = $name = "";
$error = "";
if(isset($_GET['id']))
{
$id = $_GET["id"];
$_SESSION["id"] = $id;
$query = "SELECT * FROM cust_companies WHERE SSN_cust='".$id."'";
if (!($query_run = mysqli_query($mysql_connection, $query))) {
$er = mysqli_error($mysql_connection);
$error = "<div class='alert alert-danger alert-dismissable fade in'>
<strong>$er<strong>.
</div>";
}
else
{
$row = mysqli_fetch_assoc($query_run);
$name = $row["Name"];
}
}
if(isset($_POST["submit"]))
{
//isset()
$name = isset($_POST['name']) ? $_POST['name'] : "";
//empty()
$name = !empty($_POST['name']) ? $_POST['name'] : "";
$id = $_SESSION["id"];
if(is_numeric($id))
{
if(strlen($id) == 11)
{
$query = "UPDATE cust_companies SET Name='$name' WHERE SSN_cust='$id'";
if (!mysqli_query($mysql_connection, $query)) {
$er = mysqli_error($mysql_connection);
$error = "<div class='alert alert-danger alert-dismissable fade in'>
<strong>$er<strong>.
</div>";
}
else
{
mysqli_close($mysql_connection);
header("Location:cust_companies.php");
}
}
else
{
$error = "<div class='alert alert-danger alert-dismissable fade in'>
<strong>Το ΑΜΚΑ πρέπει να είναι 11 νούμερα<strong>.
</div>";
}
}
else
{
$error = "<div class='alert alert-danger alert-dismissable fade in'>
<strong>Το ΑΜΚΑ πρέπει να είναι αριθμός<strong>.
</div>";
}
}
?>
<body>
<div class="container">
<form method="post" action = "cust_companiesUpdate.php">
<?php echo $error;?>
<div class="form-group row">
<label class="col-md-2 control-label">SSN Number</label>
<div class="col-md-5">
<input type="text" class="form-control" name="id" placeholder="SSN Number" value="<?php echo $id;?>" disabled />
</div>
</div>
<div class="form-group row">
<label class="col-md-2 control-label">Company Name</label>
<div class="col-md-5">
<input type="text" class="form-control" name="name" placeholder="Company Name" value="<?php echo $name;?>" required />
</div>
<br></br>
<div class="form-group row">
<div class="col-md-offset-2 col-md-8">
<button type="submit" class="btn btn-success" name="submit">Submit</button>
</div>
</div>
</form>
</body>
</html>