-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathalterar.php
More file actions
226 lines (176 loc) · 6.2 KB
/
Copy pathalterar.php
File metadata and controls
226 lines (176 loc) · 6.2 KB
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
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" type="text/css">
<link rel="stylesheet" href="main.css" type="text/css">
</head>
<body class="bg-faded">
<div class="p-1">
<div class="container">
<div class="row">
<div class="col-md-12">
<h1 class="text-center">infoMedicine</h1>
</div>
</div>
</div>
</div>
<div class="py-5 bg-faded">
<div class="container">
<div class="row">
<div class="col-md-12"><a href="display.php" class="btn btn-block btn-primary btn-sm" data-toggle="">Voltar</a></div>
</div>
</div>
<div class="">
<div class="container">
<div class="row">
<?php
//Pagina de demonstração realizando todas as operações na mesma pagina
//Funciona mas fica um tanto desorganizado
include 'conection.php';
if(isset($_GET['med'])){
$resulta1 = mysqli_query($conn, "SELECT * FROM `fabricante`");
$resulta2 = mysqli_query($conn, "SELECT * FROM `principio_ativo`");
$mya=$_GET['med'];
$alte=mysqli_query($conn,"SELECT * FROM `medicamento` WHERE Codigo_de_Registro='$mya'");
while ($rou1 = $alte->fetch_assoc()) {
$nom = $rou1['Nome'];
$imu = $rou1['Imagem_URL'];
$codd = $rou1['Codigo_de_Registro'];
$refe = $rou1['Referencia'];
$decr = $rou1['Descricao'];
}
?>
<form name="Medicamento" method="post" action="alterar.php">
<input type='hidden' name='batata' value="batata" />
Nome: <?php echo $nom; ?>
<input type="hidden" name="nome" value=<?php echo $nom; ?>><br/></br>
Imagem_URL:</br> <input type="URL" name="url" value=<?php echo $imu; ?>></br></br>
Codigo de Registro:</br> <input type="text" name="registro" value=<?php echo $codd; ?>></br></br>
Referência:</br> <input type="text" name="referencia" value=<?php echo $refe; ?>></br></br>
Descrição:</br> <textarea name="descricao">
<?php echo $decr; ?>
</textarea></br></br>
Fabricante:</br> <select type="text" name="fabricante">
<?php while($row1 = mysqli_fetch_array($resulta1)):;?>
<option><?php echo $row1[0];?></option>
<?php endwhile; ?>
</select></br></br>
Principio Ativo:</br> <select name="principio">
<?php while($row2 = mysqli_fetch_array($resulta2)):;?>
<option><?php echo $row2[0];?></option>
<?php endwhile; ?>
</select></br></br>
<input class="btn btn-primary" type="submit" name="Enviar" style="float: left;">
</form>
<?php
}
if(isset($_GET['fab'])){
$mya=$_GET['fab'];
$alte=mysqli_query($conn,"SELECT * FROM `fabricante` WHERE Nome='$mya'");
while ($rou2 = $alte->fetch_assoc()) {
$nom = $rou2['Nome'];
$imu = $rou2['Imagem_URL'];
$decr = $rou2['Descricao'];
$contt = $rou2['Contato'];
$ende = $rou2['Endereco'];
}
?>
<form name="Fabricante" method="post" action="alterar.php">
<input type='hidden' name='pudin' value="pudin" />
Nome: <?php echo $nom; ?>
<input type="hidden" name="nome" value=<?php echo $nom; ?>><br/></br>
URL da Imagem:</br> <input type="URL" name="url" value=<?php echo $imu; ?>></br></br>
Descricao:</br> <textarea name="descricao">
<?php echo $decr; ?>
</textarea></br></br>
Contato:</br> <textarea name="contato">
<?php echo $contt; ?>
</textarea></br></br>
Endereco: </br> <textarea name="contato">
<?php echo $ende; ?>
</textarea></br></br>
<input class="btn btn-primary" type="submit" name="Enviar" style="float: left;">
</form>
<?php
}
if(isset($_GET['pi'])){
$mya=$_GET['pi'];
$alte=mysqli_query($conn,"SELECT * FROM `principio_ativo` WHERE Nome='$mya'");
while ($rou3 = $alte->fetch_assoc()) {
$nom = $rou3['Nome'];
$decr = $rou3['Descricao'];
}
?>
<form name="Principio_Ativo" method="post" action="alterar.php">
<input type='hidden' name='bolo' value="bolo" />
<input type='hidden' name='nome' value=<?php echo $nom; ?>>
Nome: <?php echo $nom; ?></br></br>
Descricao:</br> <textarea name="descricao">
<?php echo $decr; ?>
</textarea></br></br>
<input class="btn btn-primary" type="submit" name="Enviar" style="float: left;">
</form>
<?php
}
if(isset($_POST['batata'])){
$nome=$_POST['nome'];
$url=$_POST['url'];
$registro=$_POST['registro'];
$referencia=$_POST['referencia'];
$descricao=$_POST['descricao'];
$principio=$_POST['principio'];
$fabricante=$_POST['fabricante'];
$sql = "UPDATE `medicamento` SET Imagem_URL='$url', Codigo_de_Registro='$registro', Referencia='$referencia', Descricao='$descricao', Fabricante='$fabricante', Principio_Ativo='$principio' WHERE Nome='$nome'";
if(!mysqli_query($conn,$sql))
{
echo ' Medicamento não modificado';
}
else{
echo ' Medicamento modificado';
}
echo "</br></br><h3>REDIRECIONANDO PARA A PÁGINA DE DISPLAY...</h3>";
header("refresh:2; url=display.php");
}
if(isset($_POST['pudin'])){
$nome=$_POST['nome'];
$url=$_POST['url'];
$descricao=$_POST['descricao'];
$contato=$_POST['contato'];
$endereco=$_POST['endereco'];
$sql = "UPDATE `fabricante` SET Imagem_URL='$url', Descricao='$descricao', Contato='$contato', Endereco='$endereco' WHERE Nome='$nome'";
if(!mysqli_query($conn,$sql))
{
echo ' Fabricante não modificado';
}
else{
echo ' Fabricante modificado';
}
echo "</br></br><h3>REDIRECIONANDO PARA A PÁGINA DE DISPLAY ...</h3>";
header("refresh:2; url=display.php");
}
if(isset($_POST['bolo'])){
$nome=$_POST['nome'];
$descricao=$_POST['descricao'];
$sql = "UPDATE `principio_ativo` SET Descricao='$descricao' WHERE Nome='$nome'";
if(!mysqli_query($conn,$sql))
{
echo ' Principio Ativo não modificado';
}
else{
echo ' Principio Ativo modificado';
}
echo "</br></br><h3>REDIRECIONANDO PARA A PÁGINA DE DISPLAY ...</h3>";
header("refresh:2; url=display.php");
}
?>
</div>
</div>
</div>
</div>
</div>
<script src="https://code.jquery.com/jquery-3.1.1.slim.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/tether/1.4.0/js/tether.min.js"></script>
<script src="https://pingendo.com/assets/bootstrap/bootstrap-4.0.0-alpha.6.min.js"></script>
</body>
</html>