<?PHP
include("inc/header.php");
$id = $_GET['id'];
$pass = $_GET['pass'];
if(!isset($id)){
echo "<meta http-equiv='refresh' content='0;url=index.php'>";
} else {
if(!isset($pass)){
echo "<meta http-equiv='refresh' content='0;url=index.php'>";
}
$querya = "SELECT * FROM classifieds WHERE adid = '$id' && password = '$pass'";
$a = mysql_query($querya) or die(mysql_error());
$num = mysql_num_rows($a);
if($num < 1){
echo "<script type='text/javascript'>alert('Error. Classified ID or Password Invalid! Redirecting...');</script>";
echo "<meta http-equiv='refresh' content='0;url=index.php'>";
} else {
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<?PHP include("inc/meta.php"); ?>
<title><?PHP include("inc/title.php"); ?></title>
<link href="inc/style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript">
function goto(url)
{
document.location.href=(url);
}
</script>
<style type="text/css">
<!--
.style57 {font-size: 12px}
.success {
color: #39709B;
font-family: Geneva, Arial, Helvetica, sans-serif;
font-weight:bold;
font-size: 20px;
text-decoration:none;
}
.error {
color: #39709B;
font-family: Geneva, Arial, Helvetica, sans-serif;
font-weight:bold;
font-size: 15px;
text-decoration:none;
}
.input {
background-image:url(images/input.png);
background-position:top;
background-repeat:repeat-x;
font-size:16px;
font-family:Geneva, Arial, Helvetica, sans-serif;
}
.style60 {color: #2B557B}
.style62 {font-size: 28px; font-weight: bold; font-family: Geneva, Arial, Helvetica, sans-serif; color: #000000; }
.style64 {
font-size: 18px;
font-weight: bold;
color: #2B557B;
}
.style68 {color: #000000; font-size: 22px; font-weight: bold; font-family: Geneva, Arial, Helvetica, sans-serif; }
-->
</style>
<script type="text/javascript">
<!--
function validate_form()
{
valid = true;
//Check If Name And Email Are Submitted
if ( document.sell.title.value == "" )
{
alert ( "Please enter a Title." );
valid = false;
} else {
if ( document.sell.description.value == "" )
{
alert ( "Please enter a Description." );
valid = false;
} else {
if ( document.sell.category.value == "" || document.sell.category.value == "default" )
{
alert ( "Please select a Category" );
valid = false;
} else {
if ( document.sell.price.value == "" )
{
alert ( "Please enter the Price." );
valid = false;
} else {
if ( document.sell.name.value == "" )
{
alert ( "Please enter a Contact Name." );
valid = false;
} else {
if ( document.sell.number.value == "" )
{
alert ( "Please enter a Contact Number." );
valid = false;
} else {
if ( document.sell.email.value == "" )
{
alert ( "Please enter a Contact Email." );
valid = false;
} else {
if ( document.sell.password.value == "" )
{
alert ( "Please enter a Listing Password." );
valid = false;
} else { }
}
}
}
}
}
}
}
return valid;
}
//-->
</script>
</head>
<body>
<table width="900" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="51%" height="70" valign="bottom"><a href="index.php"><img src="images/logo.gif" alt="Petoskey Classifieds - Northern Michigan Classifieds" width="450" height="62" border="0" /></a></td>
<td width="49%" class="head"><div align="right" class="style1"><a href="index.php" class="style46">Home</a> <span class="style4">|</span> <a href="buy.php" class="style46">Buy</a> <span class="style4">|</span><a href="sell.php" class="style10"> Sell </a><span class="style4">| </span><span class="style9"><a href="search.php" class="style46">Search</a> <span class="style44">|</span> <a href="help.php" class="style46">Help</a> </span></div></td>
</tr>
<tr>
<td height="226" colspan="2" valign="top" background="images/bg_sell.png" bgcolor="#F1F5FA" class="left" style="padding-left:150px;"><div align="center">
<table width="100%" height="220" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="52%"> </td>
<td width="48%"><?PHP echo $block4; ?></td>
</tr>
</table>
</div></td>
</tr>
<tr>
<td height="34" colspan="2" valign="top" class="main-content"><br />
<table width="100%" height="75" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="71%" valign="top" class="left-content"><table width="100%" border="0" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td valign="bottom"><span class="style34">Edit Classified Listings </span></td>
<td width="180" valign="bottom" style="padding-right:5px;"> </td>
</tr>
<tr>
<td height="271" colspan="2" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="#E2ECF5" style="border:1px solid #D8D8D8;" >
<tr>
<td height="200">
<?PHP
$back = "<a href='sell.php'>Click Here To Go Back And Try Again</a>";
if(isset($_GET['upload']) && $_FILES['userfile']['size'] > 0)
{
$title = $_GET['title'];
$description = $_GET['description'];
$category = $_GET['category'];
$price = $_GET['price'];
$name = $_GET['name'];
$number = $_GET['number'];
$email = $_GET['email'];
$password = $_GET['password'];
// PICTURE UPLOAD SYSTEM
$imagename = basename($_FILES['userfile']['name']);
//echo $imagename;
if(empty($imagename)) {
$error = 1;
echo"<h2 class='error'>The name of the image was not found.</h2>".$back; }
if($error != 1 && $noimg != 1)
{
$filename = stripslashes($_FILES['userfile']['name']);
$extension = substr(strrchr($filename, '.'), 1);
$extension = strtolower($extension);
//if it is not a known extension, we will suppose it is an error and will not upload the file,
//otherwise we will do more tests
}
if (($extension != "jpg") && ($extension != "jpeg") && ($extension != "png") && ($extension != "gif"))
{
//print error message
echo '<h2 class="error">Error. Images Must Be Jpg, Gif, or Png Format! Please Go Back And Try Another Image.</h2>'.$back.'';
$errors=1;
}
else
{
$time = time();
$newimage = "photos/" . $time . $imagename;
//echo $newimage;
$result = @move_uploaded_file($_FILES['userfile']['tmp_name'], $newimage);
if(empty($result)) {
$error = 1;
echo "<h2 class='error'>There was an error moving the uploaded file.</h2><br/>".$back."";
}
$date = date("Y-m-d");
$id = $_GET['id'];
$query = "UPDATE classifieds set title = '$title', description = '$description', cat = '$category', price = '$price', name = '$name', number = '$number', email = '$email', password = '$password', picture = '$newimage', date = '$date' WHERE adid = '$id'";
mysql_query($query) or die(mysql_error());
echo "<div align='justify'><h2 class='success'>Your ad '".$name."' Has Been Updated Successfully!</h2><br/></div>";
}
} elseif(isset($_GET['upload'])) {
// No Image SQL for users not posting an image with the Ad.
$title = $_GET['title'];
$description = $_GET['description'];
$category = $_GET['category'];
$price = $_GET['price'];
$name = $_GET['name'];
$number = $_GET['number'];
$email = $_GET['email'];
$password = $_GET['password'];
$date = date("Y-m-d");
$id = $_GET['id'];
$query = "UPDATE classifieds set title = '$title', description = '$description', cat = '$category', price = '$price', name = '$name', number = '$number', email = '$email', password = '$password', picture = 'images/noimage.jpg', date = '$date' WHERE adid = '$id'";
mysql_query($query) or die(mysql_error());
echo "<div align='justify'><h2 class='success'>Your ad '".$title."' Has Been Updated Successfully!</h2><br/></div>";
} else {
$i = $_GET['id'];
if(isset($i)){
$back = "SELECT * FROM classifieds WHERE adid = '$i' limit 1";
$query2 = mysql_query($back) or die (mysql_error());
while($row = mysql_fetch_array($query2, MYSQL_ASSOC)){
$newid = $row['adid'];
$title = $row['title'];
$description = $row['description'];
$category = $row['cat'];
$price = $row['price'];
$name = $row['name'];
$number = $row['number'];
$email = $row['email'];
$password = $row['password'];
$picture = $row['picture'];
$date = date("Y-m-d");
}
?>
<form action="edit.php" onsubmit="return validate_form();" method="get" name="sell" enctype="multipart/form-data">
<input type="hidden" name"pass" value="<?PHP echo $_GET['pass']; ?>"/>
<input type="hidden" name="id" value="<?PHP echo $newid; ?>" /><table width="100%" border="0" cellspacing="5" cellpadding="0">
<tr>
<td colspan="2"><span class="style68">Classified Information </span></td>
</tr>
<tr>
<td width="31%"><span class="style64">Title</span></td>
<td width="69%"><input type="text" name="title" class="input" value="<?PHP echo $title; ?>"/></td>
</tr>
<tr>
<td class="style64">Description</td>
<td><textarea name="description" rows="5" class="input"><?PHP echo $description; ?></textarea></td>
</tr>
<tr>
<td class="style64">Classified Category </td>
<td><select name="category" class="input">
<option value="default" selected="selected" style='background-color:#f1f5fa;'>Select A Category</option>
<?PHP
$catquery3 = mysql_query("SELECT * FROM categories");
while($row = mysql_fetch_array($catquery3, MYSQL_ASSOC))
{
echo "<option value='".$row['id']."' style='background-color:#f1f5fa;'>".$row['name']."</option>";
}
?>
</select></td>
</tr>
<tr>
<td class="style64">Price</td>
<td><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="34%"><table width="91%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="14%" valign="middle"><div align="left"><span class="style62">$</span></div></td>
<td width="38%"><input name="price" type="text" value="<?PHP echo $title; ?>" size="5" maxlength="5" style="background:url(images/pricebg-small.gif); background-position:center; background-repeat:no-repeat;height:45px;width:55px;text-align:center;font-size:28px;font-weight:bold;color:#fff;font-family:Geneva, Arial, Helvetica, sans-serif;border:1px solid #E2ECF5;"/></td>
<td width="48%" valign="middle"><div align="left"><span class="style62">.00</span></div></td>
</tr>
</table> </td>
<td width="21%"><img src="images/arrow-left.png" width="77" height="45" /></td>
<td width="45%"><span class="style60"><strong>Enter Your Price In White </strong><br />
<span class="style57">(Just the dollar value, ex. enter "10" for $10.00, no $ or .00)</span></span></td>
</tr>
</table></td>
</tr>
<tr>
<td height="34" colspan="2" valign="bottom"><span class="style68">Contact Information </span></td>
</tr>
<tr>
<td class="style64">Contact Name </td>
<td><input type="text" name="name" class="input" value="<?PHP echo $name; ?>" /></td>
</tr>
<tr>
<td class="style64">Contact Number </td>
<td><input type="text" name="number" class="input" value="<?PHP echo $number; ?>" /></td>
</tr>
<tr>
<td class="style64">Contact Email </td>
<td><input type="text" name="email" class="input" value="<?PHP echo $email; ?>" /></td>
</tr>
<tr>
<td class="style64">Classified Image<br />
<span class="style57">(Jpg, Gif or Png Formats)</span> </td>
<td><input type="hidden" name="MAX_FILE_SIZE" value="2000000">
<input name="userfile" type="file" class="input" id="userfile"> </td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td class="style64">Listing Password<br />
<span class="style57">(Used To Delete Ad or Mark as Sold)</span> </td>
<td><input type="text" name="password" class="input" value="<?PHP echo $password; ?>" /></td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td height="30"> </td>
<td valign="bottom"><input type="submit" name="upload" value="Continue" /></td>
</tr>
</table>
</form><?PHP } } } } ?></td>
</tr>
</table></td>
</tr>
</tbody>
</table>
<br />
<br /></td>
<td width="29%" valign="top" class="right-content"><?PHP include("inc/right.php"); ?></td>
</tr>
</table> </td></tr>
<tr>
<td height="93" colspan="2" valign="top" class="footer">
<div style="float:right;"><a href="#"><img src="images/backtotop.png" width="59" height="18" border="0" /></a></div>
<div align="left" class="style23">
<p><a href="index.php" class="style49">Home</a> <span class="style44">|</span> <a href="buy.php" class="style49">Buy</a> <span class="style44">|</span><a href="sell.php" class="style49"> Sell </a><span class="style44">| </span><span class="style49"><a href="search.php" class="style49">Search</a> <span class="style44">|</span> <a href="help.php" class="style49">Help</a></span></p>
<p class="style24"> All Rights Reserved
<?PHP include("inc/title.php"); ?>
<br />
PHP Classifieds App - <a href="http://www.rcoders.com/" style="text-decoration:none;color:#000000;">RCoders</a> Dev </p>
</div></td>
</tr>
</table>
</body>
</html>