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 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303
| <?php
/************ INCLUDE SECTION ************/
include('../../include/ErrorHandler/error_handler.php');
include('../../include/global.php');
include('../include/auth.php');
include('../../include/connection.php');
include('../../include/functions.php');
include('../../include/validation.php');
if(!isset($HTTP_GET_VARS["id"]) || $HTTP_GET_VARS["id"]=="")
die(header('location: index.php'));
$error_msg = "";
$msg = "";
if($HTTP_SERVER_VARS['REQUEST_METHOD']=="POST")
{
/**** SERVER VALIDATION ****/
if(!(chk($HTTP_POST_VARS['year'],"IsNotEmpty,IsNumber")))
$error_msg.= "- Please enter a Year<br>";
if(!(chk($HTTP_POST_VARS['model'],"IsNotEmpty")))
$error_msg.= "- Please enter a Make<br>";
if(!(chk($HTTP_POST_VARS['type'],"IsNotEmpty")))
$error_msg.= "- Please enter a Model<br>";
if(!(chk($HTTP_POST_VARS['engine'],"IsNotEmpty")))
$error_msg.= "- Please enter an Engine<br>";
if(!(chk($HTTP_POST_VARS['trans'],"IsNotEmpty")))
$error_msg.= "- Please enter a Trans<br>";
if(!(chk($HTTP_POST_VARS['drive'],"IsNotEmpty")))
$error_msg.= "- Please enter a Drive<br>";
if(!(chk($HTTP_POST_VARS['color'],"IsNotEmpty")))
$error_msg.= "- Please enter a Color<br>";
if(!(chk($HTTP_POST_VARS['millage'],"IsNotEmpty,IsNumber")))
$error_msg.= "- Please enter a valid numeric value for Millage<br>";
if(!(chk($HTTP_POST_VARS['price'],"IsMoney")))
$error_msg.= "- Please enter a valid money value for Price<br>";
if(!(chk($HTTP_POST_VARS['low'],"IsMoney")))
$error_msg.= "- Please enter a valid money value for Low Book<br>";
if(!(chk($HTTP_POST_VARS['high'],"IsMoney")))
$error_msg.= "- Please enter a valid money value for High Book<br>";
if(!(chk($HTTP_POST_VARS['certified'],"IsSelected")))
$error_msg.= "- Please select an option for Certified<br>";
if(isset($HTTP_POST_VARS['special']))
$special="Y";
else
$special="N";
if($error_msg == "")
{
#############################################################################
# IF MAGIC QUOTE IN PHP.INI IS SET OFF ADD SLASHES TO SUBMITED VARIABLES #
#############################################################################
$sql = "UPDATE ".$db_prefix."cars SET
stored='".$HTTP_POST_VARS['stored_year']."-".$HTTP_POST_VARS['stored_month']."-".$HTTP_POST_VARS['stored_day']."',
year='".add_slashes($HTTP_POST_VARS['year'])."',
model='".add_slashes($HTTP_POST_VARS['model'])."',
type='".add_slashes($HTTP_POST_VARS['type'])."',
engine='".add_slashes($HTTP_POST_VARS['engine'])."',
trans='".add_slashes($HTTP_POST_VARS['trans'])."',
drive='".add_slashes($HTTP_POST_VARS['drive'])."',
color='".add_slashes($HTTP_POST_VARS['color'])."',
millage='".add_slashes($HTTP_POST_VARS['millage'])."',
vin='".add_slashes($HTTP_POST_VARS['vin'])."',
price='".add_slashes(strip_out($HTTP_POST_VARS['price']))."',
low='".add_slashes(strip_out($HTTP_POST_VARS['low']))."',
high='".add_slashes(strip_out($HTTP_POST_VARS['high']))."',
features='".add_slashes($HTTP_POST_VARS['features'])."',
comments='".add_slashes($HTTP_POST_VARS['comments'])."',
certified='".add_slashes($HTTP_POST_VARS['certified'])."',
special= '".$special."'
WHERE id=".$HTTP_GET_VARS["id"];
if(@mysql_query($sql))
die(header("Location: index.php?status=update"));
else
$error_msg = "Record was not updated because of invalid data posted.<br>- Stock must be unique.";
}
else//if($error_msg == "")
$error_msg = "Record was not updated because of invalid data posted.<br>".$error_msg;
$member_name = $HTTP_POST_VARS["member_name"];
$stock = $HTTP_POST_VARS["stock"];
$stored_month = $HTTP_POST_VARS["stored_month"];
$stored_day = $HTTP_POST_VARS["stored_day"];
$stored_year = $HTTP_POST_VARS["stored_year"];
$year = $HTTP_POST_VARS["year"];
$model = $HTTP_POST_VARS["model"];
$type = $HTTP_POST_VARS["type"];
$engine = $HTTP_POST_VARS["engine"];
$trans = $HTTP_POST_VARS["trans"];
$drive = $HTTP_POST_VARS["drive"];
$color = $HTTP_POST_VARS["color"];
$millage = $HTTP_POST_VARS["millage"];
$vin = $HTTP_POST_VARS["vin"];
$price = $HTTP_POST_VARS["price"];
$low = $HTTP_POST_VARS["low"];
$high = $HTTP_POST_VARS["high"];
$features = $HTTP_POST_VARS["features"];
$comments = $HTTP_POST_VARS["comments"];
$certified = $HTTP_POST_VARS["certified"];
}
else
{
$sql = "SELECT c.*,CONCAT(d.first_name,' ',d.last_name) AS dealer_name
FROM ".$db_prefix."cars AS c
INNER JOIN ".$db_prefix."dealers AS d ON d.id=c.member_id
WHERE c.id=".$HTTP_GET_VARS["id"];
if($HTTP_SESSION_VARS['ses_adm_id']!=1)
$sql .= " AND c.member_id=".$HTTP_SESSION_VARS['ses_adm_id'];
$rs = @mysql_query($sql) or trigger_error('Error on executing '.$sql, E_USER_ERROR);
if(mysql_num_rows($rs)==0)
die(header("location: index.php"));
list($id,
$member_id,
$stock,
$stored,
$year,
$model,
$type,
$engine,
$trans,
$drive,
$color,
$millage,
$vin,
$price,
$low,
$high,
$features,
$comments,
$certified,
$special,
$member_name) = mysql_fetch_array($rs);
list($stored_year,$stored_month,$stored_day) = explode("-",$stored);
}//else ($HTTP_SERVER_VARS['REQUEST_METHOD']=="POST")
if($HTTP_SESSION_VARS['ses_adm_id']==1)
{
$sql_member="SELECT id,CONCAT(first_name,' ',last_name) AS name FROM ".$db_prefix."dealers ORDER BY name";
$rs_member=mysql_query($sql_member)or
trigger_error('Error on executing '.$sql_member, E_USER_ERROR);
}
/****** OUTPUT *******/
include('../include/common_top.php');
?>
<script language="javascript" src="<?=$site_URL?>include/js/FormValidator.js"></script>
<script language="javascript">
var vArray=new Array();
vArray[vArray.length]=new Array('year','IsNotEmpty,IsNumber','Please enter a Year');
vArray[vArray.length]=new Array('model','IsNotEmpty','Please enter a Make');
vArray[vArray.length]=new Array('type','IsNotEmpty','Please enter a Model');
vArray[vArray.length]=new Array('engine','IsNotEmpty','Please enter an Engine');
vArray[vArray.length]=new Array('trans','IsNotEmpty','Please enter a Trans');
vArray[vArray.length]=new Array('drive','IsNotEmpty','Please enter a Drive');
vArray[vArray.length]=new Array('color','IsNotEmpty','Please enter a Color');
vArray[vArray.length]=new Array('millage','IsNotEmpty,IsNumber','Please enter a valid numeric value for Millage');
vArray[vArray.length]=new Array('price','IsMoney','Please enter a valid money value for Price');
vArray[vArray.length]=new Array('low','IsMoney','Please enter a valid money value for Low Book');
vArray[vArray.length]=new Array('high','IsMoney','Please enter s valid money value for High Book');
vArray[vArray.length]=new Array('certified','IsSelected','Please select an option for Certified');
</script>
<p class="title">Edit Car </p>
<?php if($error_msg!=""){?><p class="wrong"><?php echo $error_msg; ?></p><?php }?>
<?php if($msg!=""){?><p class="msg"><?php echo $msg; ?></p><?php }?>
<form name="f" method="post" action="edit.php?id=<?=$HTTP_GET_VARS['id']?>" onSubmit="return validate(this)">
<input type="Hidden" name="member_name" value="<?php echo $member_name ?>">
<table cellspacing="1" cellpadding="5" class="tbl">
<tr><td colspan="2" class="tblhead">Car details</td></tr>
<?php if($HTTP_SESSION_VARS['ses_adm_id']==1) {?>
<tr>
<td class="tbltext">Dealer *</td>
<td class="tbltext" nowrap><?=$member_name ?></td>
</tr>
<?php } ?>
<tr>
<td class="tbltext">Stock *</td>
<td class="tbltext"><input type="hidden" name="stock" value="<?php echo replace_quotes($stock) ?>"><?php echo $stock ?></td>
</tr>
<tr>
<td class="tbltext">Sored *</td>
<td class="tbltext">
<select name="stored_month" class="frm1" style="width:40px">
<?php
for($i=1;$i<=12;$i++)
{
if($i<10)
$date_string = "0".$i;
else
$date_string = $i;
?>
<option value="<?php echo $date_string ?>" <?php if($date_string == $stored_month) echo "selected" ?>><?php echo $date_string ?></option>
<?php } ?>
</select> /
<select name="stored_day" class="frm1" style="width:40px">
<?php
for($i=1;$i<=31;$i++)
{
if($i<10)
$date_string = "0".$i;
else
$date_string = $i;
?>
<option value="<?php echo $date_string ?>" <?php if($date_string == $stored_day) echo "selected" ?>><?php echo $date_string ?></option>
<?php } ?>
</select> /
<select name="stored_year" class="frm1" style="width:55px">
<?php
for($i=date("Y")-15;$i<=date("Y")+5;$i++)
{
if($i<20)
$date_string = "0".$i;
else
$date_string = $i;
?>
<option value="<?php echo $date_string ?>" <?php if($date_string == $stored_year) echo "selected" ?>><?php echo $date_string ?></option>
<?php } ?>
</select>
</td>
</tr>
<tr>
<td class="tbltext">Year *</td>
<td class="tbltext"><input type="text" class="frm1" name="year" maxlength="4" value="<?php echo replace_quotes($year) ?>"></td>
</tr>
<tr>
<td class="tbltext">Make *</td>
<td class="tbltext"><input type="text" class="frm1" name="model" value="<?php echo replace_quotes($model) ?>"></td>
</tr>
<tr>
<td class="tbltext">Model *</td>
<td class="tbltext"><input type="text" class="frm1" name="type" value="<?php echo replace_quotes($type) ?>"></td>
</tr>
<tr>
<td class="tbltext">Engine *</td>
<td class="tbltext"><input type="text" class="frm1" name="engine" value="<?php echo replace_quotes($engine) ?>"></td>
</tr>
<tr>
<td class="tbltext">Trans *</td>
<td class="tbltext"><input type="text" class="frm1" name="trans" value="<?php echo replace_quotes($trans) ?>"></td>
</tr>
<tr>
<td class="tbltext">Drive *</td>
<td class="tbltext"><input type="text" class="frm1" name="drive" value="<?php echo replace_quotes($drive) ?>"></td>
</tr>
<tr>
<td class="tbltext">Color *</td>
<td class="tbltext"><input type="text" class="frm1" name="color" value="<?php echo replace_quotes($color) ?>"></td>
</tr>
<tr>
<td class="tbltext">Millage *</td>
<td class="tbltext"><input type="text" class="frm1" name="millage" value="<?php echo replace_quotes($millage) ?>"></td>
</tr>
<tr>
<td class="tbltext">VIN</td>
<td class="tbltext"><input type="text" class="frm1" name="vin" value="<?php echo replace_quotes($vin) ?>"></td>
</tr>
<tr>
<td class="tbltext">Price</td>
<td class="tbltext"><input type="text" class="frm1" name="price" value="<?php if($price != "" && $price != "0"){ if(is_numeric($price)){ echo "$".number_format($price,2);}else{ echo $price; }}?>"></td>
</tr>
<tr>
<td class="tbltext">Low Book</td>
<td class="tbltext"><input type="text" class="frm1" name="low" value="<?php if($low != "" && $low != "0"){ if(is_numeric($low)){ echo "$".number_format($low,2);}else{ echo $low; }}?>"></td>
</tr>
<tr>
<td class="tbltext">High Book</td>
<td class="tbltext"><input type="text" class="frm1" name="high" value="<?php if($high != "" && $high != "0"){ if(is_numeric($high)){ echo "$".number_format($high,2);}else{ echo $high; }}?>"></td>
</tr>
<tr>
<td class="tbltext" valign="top">Features</td>
<td class="tbltext"><textarea class="frm1" name="features" rows="7"><?php echo replace_quotes(str_replace("<br>","\n",$features)) ?></textarea></td>
</tr>
<tr>
<td class="tbltext" valign="top">Comments</td>
<td class="tbltext"><textarea class="frm1" name="comments" rows="7"><?php echo replace_quotes($comments) ?></textarea></td>
</tr>
<?php if($HTTP_SESSION_VARS['ses_adm_id']==1){?>
<tr>
<td class="tbltext">Special</td>
<td class="tbltext"><input type="checkbox" name="special" value="Y" <?php if($special == "Y")echo "checked"?>></td>
</tr>
<?php }?>
<tr>
<td class="tbltext">Certified *</td>
<td class="tbltext" nowrap>
<select name="certified" class="frm1" style="width:267px">
<option value="0" <?php if($certified == "0") echo 'selected'; ?>>Please Select</option>
<option value="no" <?php if($certified == "no") echo 'selected'; ?>>No</option>
<option value="yes" <?php if($certified == "yes") echo 'selected'; ?>>Yes</option>
</select>
</td>
</tr>
<tr><td class="tbltext" colspan="2" align="center"><input type="submit" name="submit" value="Update" class="button"></td></tr>
</table>
<p class="text"><a href="http://www.garagetoto.com/search/cession_pdf.php">certificat de cession </a></p>
</form>
<p class="text"><a href="javascript:history.back()">Back</a></p>
<?php include("../include/common_bottom.php"); ?> |
Partager