-
Notifications
You must be signed in to change notification settings - Fork 0
/
rd_editservice.php
182 lines (162 loc) · 5.04 KB
/
rd_editservice.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
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
<?php
include('config.php');
$id=$_GET['id'];
$type=array('Lender','Inspector','Lawyers','Appraisers','Builders');
if ($_POST['submitedit']!='')
{
$iname=basename($_FILES['userimage']['name']);
move_uploaded_file($_FILES['userimage']['tmp_name'], 'd:/Websites/myrealtornow.ca/images/'.$iname);
$lname=basename($_FILES['logoimage']['name']);
move_uploaded_file($_FILES['logoimage']['tmp_name'], 'd:/Websites/myrealtornow.ca/images/'.$lname);
if ($id!='')
{
$sql='update tb_services set url="'.htmlentities($_POST['url'],ENT_QUOTES).'", phone="'.htmlentities($_POST['phone'],ENT_QUOTES).'", email="'.htmlentities($_POST['email'],ENT_QUOTES).'", name="'.htmlentities($_POST['name'],ENT_QUOTES).'", company="'.htmlentities($_POST['company'],ENT_QUOTES).'",typeid='.$_POST['typeid'];
if ($iname!='')
$sql.=', personimage="'.$iname.'"';
if ($lname!='')
$sql.=', companylogo="'.$lname.'"';
$sql.=' where id='.$id;
$res=mysql_query($sql);
if ($res)
$msg='Updated Successfully';
else
$err='Updated failed '.mysql_error();
}
else
{
$sql='insert into tb_services (name,typeid,email,company,phone,url';
if ($iname!='')
$sql.=', personimage';
if ($lname!='')
$sql.=', companylogo';
$sql.=') values ("'.htmlentities($_POST['name'],ENT_QUOTES).'",'.$_POST['typeid'].',"'.htmlentities($_POST['email'],ENT_QUOTES).'", "'.htmlentities($_POST['company'],ENT_QUOTES).'", "'.htmlentities($_POST['phone'],ENT_QUOTES).'", "'.htmlentities($_POST['url'],ENT_QUOTES).'"';
if ($iname!='')
$sql.=', "'.$iname.'"';
if ($lname!='')
$sql.=', "'.$lname.'"';
$sql.=')';
$res=mysql_query($sql);
if ($res)
$msg='Inserted Successfully';
else
$err='Insertion failed '.mysql_error();
$id=mysql_insert_id();
}
}
if ($id!='')
{
$sql='select * from tb_services where id='.$id;
$res=mysql_query($sql);
$use=mysql_fetch_array($res,MYSQL_ASSOC);
$txt='Edit Service';
}
else
$txt='Create Service';
if ($err!='')
$error_msg=$err;
if ($msg!='' && $_GET['idel']=='')
{
$_SESSION['ok_msg']=$msg;
session_write_close();
header('Location: /rd_services.php');
}
else
if ($msg!='')
$ok_msg=$msg;
include('template/rd_header.php');
?>
<div class="backend_wrap">
<div style="width: 155px; float:left;">
<table class="hint">
<tr>
<td align="right">
<img src="/images/maphint.png" />
</td>
<td align="left">
* Hint
</td>
</tr>
<tr>
<td colspan="2" align="center">
In the Google Map Window, drag this icon to anywhere on the Map to access the amazing Street View.
</td>
</tr>
</table>
</div>
</div>
<div class="wrapper" style="margin: 20px auto; float:left; background: none;">
<div class="pageheader">
<p><? echo $txt; ?></p>
</div>
<form method="POST" enctype="multipart/form-data" action="<? echo $_SERVER['PHP_SELF']; if ($id!='') echo '?id='.$id;?>">
<table class="table_lists2" cellpadding="0" cellspacing="0" style="padding: 20px; width: 100%; min-width: 590px;clear:both;">
<tr>
<th width="290">Name</th>
<th width="290">E-mail</th>
<th>Company Name</th>
<th>Type</th>
</tr>
<tr>
<td><input name="name" type="text" class="rounded" value="<? echo post_or_row($use,'name');?>") /></td>
<td><input name="email" type="text" class="rounded" value="<? echo post_or_row($use,'email');?>") /></td>
<td><input name="company" type="text" class="rounded" value="<? echo post_or_row($use,'company');?>") /></td>
<td><select name="typeid" class="rounded" />
<?
for ($i=0;$i<count($type);$i++)
{
$j=$i+1;
echo '<option value='.$j;
if ($j==post_or_row($use,'typeid'))
echo ' selected ';
echo '>'.$type[$i].'</option>';
}
?>
</select></td>
</tr>
<tr>
<th>Website url</th>
<th>Phone Number</th>
</tr>
<tr>
<td><input type="text" style="width:232px;" class="rounded" name="url" value="<? echo post_or_row($use,'url');?>" /></td>
<td><input type="text" class="rounded" name="phone" value="<? echo post_or_row($use,'phone');?>" /></td>
</tr>
<tr>
<th colspan="2">User image</th>
<th>Logo image</th>
</tr>
<tr>
<td colspan="2"><input type="file" name="userimage" /></td>
<td><input type="file" name="logoimage" /></td>
</tr>
<tr>
<td><? if ($use['personimage']!='') echo '<img src="/images/'.$use['personimage'].'" border="0">'; ?></td>
<td><? if ($use['companylogo']!='') echo '<img src="/images/'.$use['companylogo'].'" border="0">'; ?></td>
</tr>
<tr>
<td colspan="3">
<input type="submit" name="submitedit" value="Save Service" class="sendinvite" />
<?
if ($error_msg!='')
echo '<img src="/images/failed.png" border=0><p style="display:inline" class="fgt_pass">'.$error_msg.'</p><br><br>';
?>
</td>
</tr>
</table>
</form>
<? include('emarentwitter.php'); ?>
</div>
</body>
</html>
<?
function post_or_row($rw,$field)
{
$val='';
if ($_POST[$field]!='')
$val=$_POST[$field];
else
if ($rw[$field]!='')
$val=$rw[$field];
return $val;
}
?>