-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathselectionFormdbTable.php
49 lines (41 loc) · 1.29 KB
/
selectionFormdbTable.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
<?php
include 'main.php';
$prop_type=$prop_error="";
if($_SERVER["REQUEST_METHOD"]=="POST"){
if(isset($_POST['property-type'])){
$sql="SELECT PropertyType FROM selectoptions WHERE PropertyType=?";
$stmt=mysqli_prepare($conn, $sql);
if($stmt){
mysqli_stmt_bind_param($stmt, "s", $param_prop_type);
$param_prop_type=trim($_POST['property-type']);
if(mysqli_stmt_execute($stmt)){
mysqli_stmt_store_result($stmt);
if(mysqli_stmt_num_rows($stmt)==1){
$prop_error="This Property type already exists";
}
else{
$prop_type=trim($_POST['property-type']);
}
}
mysqli_stmt_close($stmt);
}
}
if(empty($prop_error)){
$sql="INSERT INTO `selectoptions` (`SlNo`, `PropertyType`) VALUES (NULL, '$prop_type')";
if(mysqli_query($conn, $sql)==true){
echo "Property type added successfully";
}
else{
echo "Property type not added". mysqli_error($conn);
}
}
}
?>
<div>
<form action="" method="post">
Add Property Type:
<input type="text" name="property-type" id="property-type">
<div class="error"><?php echo $prop_error; ?></div>
<input type="submit" name="submit" id="submit">
</form>
</div>