-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheditbranch.php
More file actions
115 lines (90 loc) · 3.64 KB
/
editbranch.php
File metadata and controls
115 lines (90 loc) · 3.64 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
<!DOCTYPE HTML>
<html>
<head>
<title> Using staff details </title>
<link rel="stylesheet" href="style.css" />
</head>
<body bgcolor="white">
<h1> Branch Update conditions </h1>
<?php
$formtop='<form <action="<?php echo htmlentities($_SERVER[$redir]); ?>" method="post">';
$menu=$formtop.'<select name="second" style="display: none"> <option value=""></option></select> <input type="text" name ="third" value="" style="display: none"';
$subbutton='<input type="submit" name="formSubmit" value="Submit" /></form>';
$formdetail="";
$query="";
$wherecond="";
$result_id="";
$Address="";
$Phone="";
$Bno="";
$Position="";
$Innputform="";
if(isset($_POST['formSubmit'])) {$query= $_POST['first'];
$wherecond= $_POST['second'];
$Innputform=$_POST['third'];
if ($query && $Innputform){
$Address=$_POST["Address"];
$Phone=$_POST["Phone"];
$Bno=$_POST["Bno"];
}
}
$conn_id = @mysql_connect ("server", "id","password")
or exit ();
mysql_select_db ("Dreamhome_km32", $conn_id);
if (!$query && !$wherecond){
$formdetail.=$menu.'
<label for="first">Please choose how you like to search :</label><br>
<select name="first">
<option value="">Select an option...</option>
<option value="Update">Update</option>
</select>
<br>'.$subbutton;
}
if ($query==="Update" && !$wherecond){
$result_id = mysql_query ("select Bno from branch") or exit ();
if ($result_id){
PrintF("<p>Please select Branch No : </p>");
$menu=$formtop.'<select name="first" style="display: none">
<option value='.$query.'></option>
</select> <input type="text" name ="third" value="" style="display: none"';
$menu.="<label for='second'> Search parameters : </label> <select name='second'><option value=''>Select branch...</option>";
while ($row = mysql_fetch_array ($result_id)){
$menu.="<option value=".$row["Bno"].">".$row["Bno"]."</option>";
}
$menu.=$subbutton;
mysql_free_result ($result_id);
}
}
if ($query==="Update" && $wherecond){
$result_id = mysql_query ("select * from branch where Bno='".$wherecond."'") or exit ();
$formdetail=$formtop.'<select name="second" style="display: none"> <option value='.$wherecond.'></option></select>
<input type="text" name ="third" value="True" style="display: none">
<select name="first" style="display: none">
<option value='.$query.'></option>
</select>';
if ($result_id){
$row = mysql_fetch_assoc ($result_id);
printf($formdetail.
"<br>Branch No. : <input type='text' name ='Bno' value='".$row["Bno"]."' readonly>".
"<br> Address : <input type='text' name ='Address' value='".$row["Street"]."'>".
"<br> Telephone :<input type='text' name ='Phone' value='".$row["Tel_No"]."'>".$subbutton);
}
}
if ($Innputform){
$formdetail=$formtop.'<select name="second" style="display: none"> <option value=""></option></select>
<input type="text" name ="third" value="True" style="display: none" ><select name="first" style="display: none">
<option value=""></option> </select>';
if ($query==="Update"){
if( mysql_query ("Update branch SET Street='".$Address."', Tel_No='".$Phone."' where Bno='".$wherecond."'" ) ){
printf("Updated");}
else { printf("Failed update");}
}
$formdetail=$formtop.'<select name="second" style="display: none"> <option value=""></option></select>
<input type="text" name ="third" value="True" style="display: none" <select name="first" style="display: none">
<option value=""></option> </select><a href="index.html"> Back to index </a>';
}
?>
<span><?php printf( $formdetail); ?> </span>
<span><?php printf( $menu); ?> </span>
</body>
</html>