Location: PHPKode > scripts > PHP Classified script made easy > php-classified-script-made-easy/openclassifiedsdownload24124/Files/sell.php
<!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: #000000;
	font-family: Geneva, Arial, Helvetica, sans-serif;
	font-size: 20px;
	text-decoration:none;
	padding:20px;
}
.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%">&nbsp;</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">Search Classified Listings </span></td>
                <td width="180" valign="bottom" style="padding-right:5px;">&nbsp;</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 
					  include("inc/header.php");
					  $back = "<a href='sell.php'>Click Here To Go Back And Try Again</a>";
if(isset($_POST['upload']) && $_FILES['userfile']['size'] > 0)
{
$title = $_POST['title'];
$description = $_POST['description'];
$category = $_POST['category'];
$price = $_POST['price'];
$name = $_POST['name'];
$number = $_POST['number'];
$email = $_POST['email'];
$password = $_POST['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 G:i:s") ; 
$query = "INSERT INTO classifieds (adid, title, description, cat, price, name, number, email, password, picture, date, views, authorized ) VALUES ('', '$title', '$description', '$category', '$price', '$name', '$number', '$email', '$password', '$newimage', '$date', '0', '0')";
mysql_query($query) or die(mysql_error());

$pullback = "SELECT * FROM classifieds WHERE title = '$title' AND email ='$email' limit 1";
$query2 = mysql_query($pullback) or die (mysql_error());
while($row = mysql_fetch_array($query2, MYSQL_ASSOC)){
$newid = $row['adid'];
$pass = $row['pass'];
}

///////////////////////////
//////////////////////////EMAIL EDIT
///////////////////////////
// EDIT THE SENT EMAIL HERE... EDIT $EMAIL BELOW TO CHANGE THE FROM EMAIL, EDIT NAME TO CHANGE THE FROM NAME, EDIT MAIL_BODY/SUBJECT TO CHANGE WORDINGS
///////////////////////////
///////////////////////////
$url = "http://";
$url .= getenv("HTTP_HOST"); // CHANGE THIS TO THE WEBSITES URL IF IT ISNT RIGHT IN EMAILS
$Name = "Classifieds";
$emailf = "hide@address.com";
$recipient = $email;
// CHANGE THE FOLLOWING IF THE LINKS ARE NOT WORKING RIGHT. YOU MAY MANUALLY CHANGE THE LINKS.
$mail_body = "Thank you for posting a new classified! <br/><br/>You May Now Manage Your Ad:<br/><br/>APPROVE AD: <a href='".$url."/approve.php?id=".$newid."&pass=".$password."'>Click Here</a><br/>EDIT AD: <a href='$url/edit.php?id=".$newid."&pass=".$password."'>Click Here</a><br/>REMOVE AD: <a href='".$url."/remove.php?id=".$newid."&pass=".$password."'>Click Here</a>";
$subject = "Classified Ad Details";
$headers = "From: ". $Name . " <" . $emailf . ">\r\n";
$headers .= "Content-type: text/html\r\n"; 

mail($recipient, $subject, $mail_body, $headers);

echo "<div align='justify'><div class='success'>Your ad '".$name."' Has Been Submitted Successfully! <br/><br/>Please take note: Your ad will not show on the website until you verify it via the email sent to you. This email also allows you to edit and remove your ad as well.</div></div>";

}
} elseif(isset($_POST['upload'])) {
// No Image SQL for users not posting an image with the Ad.
$title = $_POST['title'];
$description = $_POST['description'];
$category = $_POST['category'];
$price = $_POST['price'];
$name = $_POST['name'];
$number = $_POST['number'];
$email = $_POST['email'];
$password = $_POST['password'];
$date = date("Y-m-d G:i:s") ; 

$query = "INSERT INTO classifieds (adid, title, description, cat, price, name, number, email, password, picture, date, views, authorized ) VALUES ('', '$title', '$description', '$category', '$price', '$name', '$number', '$email', '$password', 'images/noimage.jpg', '$date', '0', '0')";
mysql_query($query) or die(mysql_error());

$pullback = "SELECT * FROM classifieds WHERE title = '$title' AND email ='$email' limit 1";
$query2 = mysql_query($pullback) or die (mysql_error());
while($row = mysql_fetch_array($query2, MYSQL_ASSOC)){
$newid = $row['adid'];
$pass = $row['pass'];
}

///////////////////////////
//////////////////////////EMAIL EDIT
///////////////////////////
// EDIT THE SENT EMAIL HERE... EDIT $EMAIL BELOW TO CHANGE THE FROM EMAIL, EDIT NAME TO CHANGE THE FROM NAME, EDIT MAIL_BODY/SUBJECT TO CHANGE WORDINGS
///////////////////////////
///////////////////////////
$url = "http://";
$url .= getenv("HTTP_HOST"); // CHANGE THIS TO THE WEBSITES URL IF IT ISNT RIGHT IN EMAILS
$Name = "Classifieds";
$emailf = "hide@address.com";
$recipient = $email;
// CHANGE THE FOLLOWING IF THE LINKS ARE NOT WORKING RIGHT. YOU MAY MANUALLY CHANGE THE LINKS.
$mail_body = "Thank you for posting a new classified! <br/><br/>You May Now Manage Your Ad:<br/><br/>APPROVE AD: <a href='".$url."/approve.php?id=".$newid."&pass=".$password."'>Click Here</a><br/>EDIT AD: <a href='$url/edit.php?id=".$newid."&pass=".$password."'>Click Here</a><br/>REMOVE AD: <a href='".$url."/remove.php?id=".$newid."&pass=".$password."'>Click Here</a>";
$subject = "Classified Ad Details";
$headers = "From: ". $Name . " <" . $emailf . ">\r\n";
$headers .= "Content-type: text/html\r\n"; 

mail($recipient, $subject, $mail_body, $headers);

echo "<div align='justify'><div class='success'>Your ad '".$name."' Has Been Submitted Successfully! <br/><br/>Please take note: Your ad will not show on the website until you verify it via the email sent to you. This email also allows you to edit and remove your ad as well.</div></div>";

} else {
					  ?>
					  <form action="sell.php" onsubmit="return validate_form();" method="post" name="sell" enctype="multipart/form-data"><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"/></td>
                          </tr>
                          <tr>
                            <td class="style64">Description</td>
                            <td><textarea name="description" rows="5" class="input"></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 WHERE sub='0'");
while($row = mysql_fetch_array($catquery3, MYSQL_ASSOC))
{
	echo "<option value='".$row['id']."' style='background-color:#f1f5fa;'>".$row['name']."</option>";
	$subcat  = mysql_query("SELECT * FROM categories WHERE parent = '".$row['id']."'");
while($row2 = mysql_fetch_array($subcat, MYSQL_ASSOC))
{
echo "<option value='".$row2['id']."' style='background-color:#f1f5fa;'> - ".$row2['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="10" size="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:#000000;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 </strong><br />
                                      <span class="style57">(Just the dollar value, ex. enter &quot;10&quot; 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" /></td>
                          </tr>
                          <tr>
                            <td class="style64">Contact Number </td>
                            <td><input type="text" name="number" class="input" /></td>
                          </tr>
                          <tr>
                            <td class="style64">Contact Email </td>
                            <td><input type="text" name="email" class="input" /></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>&nbsp;</td>
                            <td>&nbsp;</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" /></td>
                          </tr>
                          <tr>
                            <td>&nbsp;</td>
                            <td>&nbsp;</td>
                          </tr>
                          <tr>
                            <td height="30">&nbsp;</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>
Return current item: PHP Classified script made easy