-
Notifications
You must be signed in to change notification settings - Fork 1
/
edit.php
106 lines (87 loc) · 4.14 KB
/
edit.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
<?php include('header.php');?>
<?php include('connection.php');?>
<?php
if( isset( $_GET['txtID'] ) ){
//Retreving data of correspondent id
$txtID=( isset($_GET['txtID']) )?$_GET['txtID']:"";
$sentence=$connection->prepare("SELECT * FROM `properties` WHERE id=$txtID");
$sentence->execute();
$registro=$sentence->fetch(PDO::FETCH_LAZY);
// $txtID=$registro['id'];
$nameProject=$registro['name'];
$image= $registro['image'];
$description=$registro['description'];
$address=$registro['address'];
$city=$registro['city'];
$status=$registro['status'];
$price=$registro['price'];
}
if($_POST){
$txtID=( isset ($_POST['txtID']))? $_POST['txtID']:"";
$nameProject=(isset ($_POST['nameProject']))? $_POST['nameProject']:"" ;
$image=(isset ($_POST['image']))? $_POST['image']:"";
$description=(isset ($_POST['description']))? $_POST['description']:"" ;
$address=(isset ($_POST['address']))? $_POST['address']:"" ;
$city=(isset ($_POST['city']))? $_POST['city']:"" ;
$status=(isset ($_POST['status']))? $_POST['status']:"" ;
$price=(isset ($_POST['price']))? $_POST['price']:"" ;
$sql="UPDATE properties
SET
name=:name,
image=:image,
description=:description,
address=:address,
city=:city,
status=:status,
price=:price
WHERE id=:id";
$sentence=$connection->prepare($sql);
$sentence->bindParam(":name",$nameProject);
$sentence->bindParam(":image",$image);
$sentence->bindParam(":description",$description);
$sentence->bindParam(":address",$address);
$sentence->bindParam(":city",$city);
$sentence->bindParam(":status",$status);
$sentence->bindParam(":price",$price);
$sentence->bindParam(":id",$txtID);
$sentence->execute();
}
?>
<br/>
<div class="container">
<div class="row">
<div class="col-md-4">
<!----------->
<div class="card">
<div class="card-header">
Project Information
</div>
<div class="card-body">
<form action="edit.php" method="post" enctype="multipart/form-data">
<div class="mb-3">
<label for="txtID" class="form-label">ID:</label>
<input value="<?php echo $txtID; ?>" type="text"
class="form-control" readonly name="txtID" id="txtID" aria-describedby="helpId" placeholder="ID">
</div>
<!-- nameproject es el nombre que entro por teclado, y que se guarda en la columna name de la base de datos-->
Name of project: <input value="<?php echo $nameProject; ?>" class="form-control" type="text" name="nameProject" id="">
<br/>
Image of project: <input value="<?php echo $image; ?>" class="form-control" type="text" name="image" id="">
<br/>
Description:
<input value="<?php echo $description; ?>" class="form-control" type="text" name="description" id="" cols="30" rows="4"></input>
<br/>
Address: <input value="<?php echo $address; ?>" class="form-control" type="text" name="address" id="">
<br/>
city: <input value="<?php echo $city; ?>" class="form-control" type="text" name="city" id="">
<br/>
Status:<input value="<?php echo $status; ?>" class="form-control" type="text" name="status" id="">
<br/>
Price: <input value="<?php echo $price; ?>" class="form-control" type="text" name="price" id="">
<br/>
<input class="btn btn-success" type="submit" value="Update info">
</form>
</div>
</div>
<!-------->
</div>