forked from estadao-digital/test-dev
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapi.php
More file actions
34 lines (22 loc) · 656 Bytes
/
api.php
File metadata and controls
34 lines (22 loc) · 656 Bytes
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
<?php
//Aqui já realizava o processo baseado no banco mysql para tornar dinamico, diferente do arquivo base criado xml.
$db = new PDO('mysql:host=localhost;dbname=ajaxdata','root','');
$page = isset($_GET['p'])?$_GET['p']:'';
if($page=='add'){
$marca = $_POST['marca'];
$modelo = $_POST['modelo'];
$ano = $_POST['ano'];
$stmt = $db->prepare("insert into crud values('',?, ?, ?)");
$stmt->binParam(1,$marca);
$stmt->binParam(2,$modelo);
$stmt->binParam(3,$ano);
if($stmt->execute()) {
echo "Carro adicionado com sucesso.";
} else {
echo "Falha na inclusão!";
}
} elseif ($page=='edit') {
} elseif ($page=='del') {
} else {
}
?>