Redimensionner photo php
Fermé
G4uthier
Messages postés
131
Date d'inscription
dimanche 2 décembre 2007
Statut
Membre
Dernière intervention
23 juillet 2009
-
15 avril 2008 à 11:22
G4uthier Messages postés 131 Date d'inscription dimanche 2 décembre 2007 Statut Membre Dernière intervention 23 juillet 2009 - 22 avril 2008 à 15:59
G4uthier Messages postés 131 Date d'inscription dimanche 2 décembre 2007 Statut Membre Dernière intervention 23 juillet 2009 - 22 avril 2008 à 15:59
A voir également:
- Redimensionner photo php
- Partage photo - Guide
- Photo aérienne de ma maison - Guide
- Traduction photo - Guide
- Photo filtre 7 gratuit - Télécharger - Retouche d'image
- Photo de profil - Guide
21 réponses
R4f
Messages postés
441
Date d'inscription
dimanche 13 janvier 2008
Statut
Membre
Dernière intervention
5 mai 2008
62
17 avril 2008 à 22:38
17 avril 2008 à 22:38
Salut,
Tu utilises bien https://www.verot.net/php_class_upload.htm ?
A ton script, il manque un require_once('class.upload.php');, non ?
Raph
Tu utilises bien https://www.verot.net/php_class_upload.htm ?
A ton script, il manque un require_once('class.upload.php');, non ?
Raph
G4uthier
Messages postés
131
Date d'inscription
dimanche 2 décembre 2007
Statut
Membre
Dernière intervention
23 juillet 2009
7
17 avril 2008 à 23:40
17 avril 2008 à 23:40
oui il est en haut de ma page c'est qu une partie de mon code ca.
R4f
Messages postés
441
Date d'inscription
dimanche 13 janvier 2008
Statut
Membre
Dernière intervention
5 mai 2008
62
17 avril 2008 à 23:44
17 avril 2008 à 23:44
Ce qui serait bien, pour que l'aide puisse porter ses fruits :
1- réduire le code à la partie qui bugge
2- mettre le code qui devrait marcher sur le forum.
Sinon, là on ne peut rien tester chez nous, on doit tatonner dans le vide, on te fait perdre du temps et tout le monde y perd.
Il faut nous aider à t'aider, tu vois ?
Raph
1- réduire le code à la partie qui bugge
2- mettre le code qui devrait marcher sur le forum.
Sinon, là on ne peut rien tester chez nous, on doit tatonner dans le vide, on te fait perdre du temps et tout le monde y perd.
Il faut nous aider à t'aider, tu vois ?
Raph
G4uthier
Messages postés
131
Date d'inscription
dimanche 2 décembre 2007
Statut
Membre
Dernière intervention
23 juillet 2009
7
17 avril 2008 à 23:56
17 avril 2008 à 23:56
le code est énorme désolé. lorsque je réduis le probleme disparait mais je vois pas de ou ca vient
session_start();
include "../common.php";
include('class.upload.php');
//Check if the user has logged in
include "checkLoginSession.php";
//COLLECT POST data
$postcode = $_POST['postcode'];
$postcode = strip_tags($postcode);
$postcode = strtoupper($postcode);
$price = $_POST['price'];
$price = strip_tags($price);
$branch = $_POST['branch'];
$branch = strip_tags($branch);
$bedrooms = $_POST['bedrooms'];
$bedrooms = strip_tags($bedrooms);
$address1 = $_POST['address1'];
$address1 = strip_tags($address1);
$address2 = $_POST['address2'];
$address2 = strip_tags($address2);
$address3 = $_POST['address3'];
$address3 = strip_tags($address3);
$agentDescription = $_POST['agentDescription'];
$agentDescription = strip_tags($agentDescription);
//$propWeek = $_POST['propWeek'];
//$propWeek = strip_tags($propWeek);
$Propertyid = $_POST['Propertyid'];
$Propertyid = strip_tags($Propertyid);
$img = $_FILES['img']['name'];
$img = strip_tags($img);
$imgFullPath = $_POST['img'];
$imgFullPath = strip_tags($imgFullPath);
//Form Error Indicators
//Collect GET vars
$message = $_GET['message'];
//$message = strip_tags($message);
$postcodeError = $_GET['postcodeError'];
$postcodeError = strip_tags($postcodeError);
$priceError = $_GET['priceError'];
$priceError = strip_tags($priceError);
$branchError = $_GET['branchError'];
$branchError = strip_tags($branchError);
$bedroomsError = $_GET['bedroomsError'];
$bedroomsError = strip_tags($bedroomsError);
$address1Error = $_GET['address1Error'];
$address1Error = strip_tags($address1Error);
$address2Error = $_GET['address2Error'];
$address2Error = strip_tags($address2Error);
$address3Error = $_GET['address3Error'];
$address3Error = strip_tags($address3Error);
$entranceError = $_GET['entranceError'];
$entranceError = strip_tags($entranceError);
$loungeError = $_GET['loungeError'];
$loungeError = strip_tags($loungeError);
$kitchenError = $_GET['kitchenError'];
$kitchenError = strip_tags($kitchenError);
$bedroom1Error = $_GET['bedroom1Error'];
$bedroom1Error = strip_tags($bedroom1Error);
$bedroom2Error = $_GET['bedroom2Error'];
$bedroom2Error = strip_tags($bedroom2Error);
$bedroom3Error = $_GET['bedroom3Error'];
$bedroom3Error = strip_tags($bedroom3Error);
$bedroom4Error = $_GET['bedroom4Error'];
$bedroom4Error = strip_tags($bedroom4Error);
$bedroom5Error = $_GET['bedroom5Error'];
$bedroom5Error = strip_tags($bedroom5Error);
$bathroomsError = $_GET['bathroomsError'];
$bathroomsError = strip_tags($bathroomsError);
$tenureError = $_GET['tenureError'];
$tenureError = strip_tags($tenureError);
$garageGardensError = $_GET['garageGardensError'];
$garageGardensError = strip_tags($garageGardensError);
$agentDescriptionError = $_GET['agentDescriptionError'];
$agentDescriptionError = strip_tags($agentDescriptionError);
$propWeekError = $_GET['propWeekError'];
$propWeekError = strip_tags($propWeekError);
$statusError = $_GET['statusError'];
$statusError = strip_tags($statusError);
$CreateRecord = $_GET['CreateRecord'];
$CreateRecord = strip_tags($CreateRecord);
//Collect GET data for SAVED data
//$savedData.=
$postcodeSave = $_GET['postcodeSave']; $savedData.= "postcodeSave=$postcode&" ;
$priceSave = $_GET['priceSave']; $savedData.= "priceSave=$price&";
$branchSave = $_GET['branchSave']; $savedData.= "branchSave=$branch&";
$bedroomsSave = $_GET['bedroomsSave']; $savedData.= "bedroomsSave=$bedrooms&";
$address1Save = $_GET['address1Save']; $savedData.= "address1Save=$address1&";
$address2Save = $_GET['address2Save']; $savedData.= "address2Save=$address2&";
$address3Save = $_GET['address3Save']; $savedData.= "address3Save=$address3&";
$entranceSave = $_GET['entranceSave']; $savedData.= "entranceSave=$entrance&";
$loungeSave = $_GET['loungeSave']; $savedData.= "loungeSave=$lounge&";
$kitchenSave = $_GET['kitchenSave']; $savedData.= "kitchenSave=$kitchen&";
$bedroom1Save = $_GET['bedroom1Save']; $savedData.= "bedroom1Save=$bedroom1&";
$bedroom2Save = $_GET['bedroom2Save']; $savedData.= "bedroom2Save=$bedroom2&";
$bedroom3Save = $_GET['bedroom3Save']; $savedData.= "bedroom3Save=$bedroom3&";
$bedroom4Save = $_GET['bedroom4Save']; $savedData.= "bedroom4Save=$bedroom4&";
$bedroom5Save = $_GET['bedroom5Save']; $savedData.= "bedroom5Save=$bedroom5&";
$bathroomsSave = $_GET['bathroomsSave']; $savedData.= "bathroomsSave=$bathrooms&";
$tenureSave = $_GET['tenureSave']; $savedData.= "tenureSave=$tenure&";
$garageGardensSave = $_GET['garageGardensSave']; $savedData.= "garageGardensSave=$garageGardens&";
$agentDescriptionSave = $_GET['agentDescriptionSave']; $savedData.= "agentDescriptionSave=$agentDescription&";
$agentNotesSave = $_GET['agentNotesSave']; $savedData.= "agentNotesSave=$agentNotes&";
$statusSave = $_GET['statusSave']; $savedData.= "statusSave=$status&";
$propWeekSave = $_GET['propWeekSave']; $savedData.= "propWeekSave=$propWeek&";
$agentIDSave = $_GET['agentIDSave']; $savedData.= "agentIDSave=$agentID&";
$imgSave = $_GET['imgSave']; $savedData.= "imgSave=$img&";
//SETUP SELECTION Dropdowns
//Updated 9.11.06
//To Fix issues with two option being display
//Branch
if($CreateRecord==1){
//Check for empty fields and setup css error var
if(!is_numeric($Bedrooms) or !is_numeric($price )){
$message=" Please check if fields Bedrooms and Price are numerics";}
if(empty($postcode)){
//Sets up a css class to indicate the field error on the form
$postcodeError = "postcodeError";
$errorString.= "postcodeError=$postcodeError&";
}
if(empty($price)||(!is_numeric($price))){
//Sets up a css class to indicate the field error on the form
$priceError = "priceError";
$errorString.= "priceError=$priceError&";
}
if(empty($branch)){
//Sets up a css class to indicate the field error on the form
$branchError = "branchError";
$errorString.= "branchError=$branchError&";
}
if(empty($bedrooms )||(!is_numeric($bedrooms))){
//Sets up a css class to indicate the field error on the form
$bedroomsError = "bedroomsError";
$errorString.= "bedroomsError=$bedroomsError&";
}
if(empty($address2)){
//Sets up a css class to indicate the field error on the form
$address2Error = "address2Error";
$errorString.= "address2Error=$address2Error&";
}
if(empty($address3)){
//Sets up a css class to indicate the field error on the form
$address3Error = "address3Error";
$errorString.= "address3Error=$address3Error&";
}
if(empty($agentDescription)){
//Sets up a css class to indicate the field error on the form
$agentDescriptionError = "agentDescriptionError";
$errorString.= "agentDescriptionError=$agentDescriptionError&";
}
//Combine Error Data into one string
$errorString .= $savedData ;
$errorParse .= $errorString ;
//New routine for generating errors -- Uses $errorString to construct the GET vars
if(!is_numeric($bedrooms)||!is_numeric($price)){
header("location: $PHP_SELF?message=$message&$errorParse");
exit();}
if(empty($postcode) || empty($price) || empty($branch) || empty($bedrooms) || empty($address2) || empty($address3) || empty($agentDescription)){
$message= "Please check the form for missing data in hightlighted fields";
header("location: $PHP_SELF?message=$message&$errorParse");
exit();
}
DBConnect();
$Link = mysql_connect($Host, $User, $Password);
$agentID = $_SESSION['userID'];
//-------Routine for Dealing With Property Of Week-------//
//Sets the Flag to NO for all properties if the current property is SET to YES
$Query_propWeek= "SELECT id, propWeek FROM $table1 WHERE propWeek = 'Yes'";
$Result_propWeek = mysql_db_query ($DBName, $Query_propWeek, $Link);
while($Row_propWeek = mysql_fetch_array($Result_propWeek)){
$Row = $Row_propWeek[id] ;
$Query_updatePropWeek = "UPDATE $table1 SET propWeek = 'No' WHERE id = $Row";
if (mysql_db_query ($DBName, $Query_updatePropWeek, $Link)){
//echo "Properties Propweek changed";
}
}
$propWeek = "Yes";
$imgpath = "propertyImages/tmp.jpg";
$imgpath2 = "propertyImages/tmp2.jpg";
$address1 = "notUsed";
$Query = "INSERT INTO $table1 VALUES ('0', '$postcode', '$price', '$branch', '$bedrooms', '$address1', '$address2', '$address3', '$agentDescription', '$propWeek', '$agentID', '$imgpath', '$imgpath2')";
if (mysql_db_query ($DBName, $Query, $Link)){
//Need to copy the img file
//Bug fix on 27.07.07 we were not getting reliable number matches for the img fields
//This new routine is more complex but fixes the bug
//We now need to change to add image routine so that the image matches the id exactly
if(empty($img)){
$img = "none";
$img2 = "none";
}else{
//Peform Select Query To Find THIS record only - It must match exactly
$Query = "SELECT id, propWeek FROM $table1 WHERE propWeek = 'Yes'";
$Result = mysql_db_query ($DBName, $Query, $Link);
$Row = mysql_fetch_array($Result);
$Propertyid = $Row[id];
//Generate the new img paths
$file1 = $Propertyid;
$file2 = $Propertyid;
$file1 = "propertyThumb".$file1 ;
$f = "propertyThumb".$file2 ;
$f = $f.=".jpg";
$fileLarge = "propertyLarge".$file2 ;
$fileLarge = $fileLarge.=".jpg";
$imgpath = "propertyImages/$f";
$imgpath2 = "propertyImages/$fileLarge";
//Peform UPDATE query to add in the new data for the img feilds
$Query2 = "UPDATE $table1 SET img = '$imgpath', img2 = '$imgpath2' WHERE id = $Propertyid";
mysql_db_query ($DBName, $Query2, $Link)or die(mysql_error());
}
copy($_FILES['img']['tmp_name'], "../propertyImages/$fileLarge");
//Handle the image processing in the class
$handle = new upload($_FILES['img']);
if ($handle->uploaded) {
/* $handle->file_new_name_body = $file1;
$handle->file_new_name_ext = 'jpg';
$handle->image_resize = true;
$handle->image_x = 200;
$handle->image_y = 200;
$handle->image_ratio_y = true;
$handle->image_ratio_x = true;
$handle->jpeg_quality = 100; */
/* $handle->image_text = '$title';
$handle->image_text_direction = 'h';
$handle->image_text_color = '#FF0000';
$handle->image_text_percent = 50;
$handle->image_text_font = 4;
$handle->image_text_y = 5;
$handle->image_text_x = 5; */
// $handle->process('../propertyImages');
/*
if ($handle->processed) {
echo 'image resized';
$handle->clean();
} else {
echo 'error : ' . $handle->error;
} */
}
$Query3 = "SELECT MAX(id) FROM $table1";
$Result = mysql_db_query ($DBName, $Query3, $Link);
$Row = mysql_fetch_array($Result);
$new = $Row['MAX(id)'];
$message = "Property Created Successfully! <br /><a href='YourURL../displayPropFullDetails.php?propertySelect=$new target=_blank'><br />Click Here To Review New Property</a>";
header("location: $PHP_SELF?message=$message");
}else{
$message = "Error Creating Property";
header("location: $PHP_SELF?message=$message");
}
mysql_close($Link);
}
?>
<!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" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>SMARTMOVE CMS Lettings and Management Ltd :: Administrator Page</title>
<!--Style Sheet-->
<?php echo $postcode ; ?>
<link href="../mainstyle.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" type="text/css" href="../AdminSmartmove.css" />
<link rel="stylesheet" type="text/css" href="../dataDisplay.css" />
<link rel="Shortcut Icon" href="favicon.ico"/>
<script src="Scripts/AC_RunActiveContent.js" type="text/javascript"></script>
<script src="Scripts/swfobject.js" type="text/javascript"></script></head>
<body>
<!--Main Content Area-->
<div id="content">
<div id="header">
<!--Main Navigation-->
<ul>
<li><span id="button1"><a href="../index.php" title="Click to view Home Page"></a></span></li>
<li><span id="button2"><a href="../about.php" title="Click to view About us Page"></a></span></li>
<li><span id="button3"><a href="../services.php" title="Click to view Services Page"></a></span></li>
<li><span id="button4"><a href="../properties.php" title="Click to view Properties Page"></a></span></li>
<li><span id="button5"><a href="../region.php" title="Click to view Region Page"></a></span></li>
<li><span id="button6"><a href="../contact.php" title="Click to view Contact Page"></a></span></li>
</ul>
<div id="adminLink">
<a href="admin/index.php"><img src="../images/transparent.gif" title="Click to go to Administrator Page" alt="Click to go to Administrator Page" width="10" height="10" border="0" /></a></div>
<div id="emailLink">
<a href="mailto:andrew@smartmove.com"><img src="../images/transparent.gif" title="Click to send email to webmaster@smartmove.com" alt="Click to send email to webmaster@smartmove.com" width="10" height="10" border="0" /></a></div>
<div id="sitemapLink">
<a href="sitemap.php"><img src="../images/transparent.gif" title="Click to view Site Map Page" alt="Click to view Site Map Page" width="10" height="10" border="0" /></a></div>
<!--Close header-->
</div>
<div id="container">
<div id="headerBox">
<div id="adminImage">
<img src="../images/admin_img.jpg" alt="Administrator Access" title="Administrator Access" width="412" height="54" /></div>
<!--Property Search-->
<div id="adminMenu">
<!--to show admin menu-->
<?php include("adminMenu.php"); ?>
<form method="post" action="" id="systemMessage">
<fieldset>
<legend>System Message</legend>
<?php echo $message;?>
</fieldset>
</form>
</div>
<div id="adminText">
<form action="addNewProperty.php?CreateRecord=1" method="post" enctype="multipart/form-data" name="form1" id="genericForm">
<fieldset>
<legend>Add New Property</legend>
<div><label for="Address2">Street</label><input id="address2" name="address2" type="text" class="<?php echo $address2Error ; ?>" value="<?php echo $address2Save ; ?>" /></div>
<div><label for="Address3">Town</label><input id="address3" name="address3" type="text" class="<?php echo $address3Error ; ?>" value="<?php echo $address3Save ; ?>" /></div>
<div><label for="Postcode">Postcode</label><input id="postcode" name="postcode" type="text" size="8" class="<?php echo $postcodeError ; ?>" value="<?php echo $postcodeSave ; ?>" />
</div>
<div><label for="Bedrooms">Bedrooms</label>
<input id="bedrooms" name="bedrooms" type="text" class="<?php echo $bedroomsError ; ?>" value="<?php echo $bedroomsSave ; ?>" size="2" />
</div>
<div><label for="Price">Price</label><input id="price" name="price" type="text" size="8" class="<?php echo $priceError ; ?>" value="<?php echo $priceSave ; ?>" />
</div>
<div>
<label for="branch">Area</label>
<select id="branch" name="branch" size="1" class="branch">
<?php if(empty($branchSave)){
echo"<option selected='selected'>Yarm</option>
<option>Eaglescliffe</option>
<option>Stokesley</option>
<option>Ingleby Barwick</option>
<option>Middlesbrough</option>
<option>Other Villages</option></select> ";
}else{
$j=0;
$Town = Array('Yarm','Eaglescliffe','Stokesley','Ingleby Barwick','Middlesbrough','Other Villages');
echo "<option selected='selected'>".$branchSave."</option>";
$j=0;
while($j<=5){
if($branchSave==$Town[$j]){
$j=$j+1;
}else{
$name=$Town[$j];
echo "<option>".$name."</option>";
$j=$j+1;
}
}
echo"</select>";
}
?>
</div>
<div><label for="agentDescription">Agent Description</label>
<textarea id="agentDescription" name="agentDescription" class="<?php echo $agentDescriptionError ; ?>"><?php echo $agentDescriptionSave ; ?></textarea>
</div>
<div><label for="file">Property Image</label>
<input id="img" name="img" type="file" value="<?php echo $imgSave ; ?>" /></div>
<div class="submit"><input name="Submit" type="Submit" class="btn" value="Add Property" /></div>
</fieldset>
</form>
</div>
<!--Info Text-->
<!--Contact Text-->
<!--Footer Info-->
</div>
</div>
</div>
<div id="footer">
<!--CSS Rollover Image Hack-->
<div class="cssRolloverImageHack_1"></div>
<div class="cssRolloverImageHack_2"></div>
<div class="cssRolloverImageHack_3"></div>
<div class="cssRolloverImageHack_4"></div>
<div class="cssRolloverImageHack_5"></div>
<div class="cssRolloverImageHack_6"></div>
<!--end footer-->
</div>
</body>
</html>
session_start();
include "../common.php";
include('class.upload.php');
//Check if the user has logged in
include "checkLoginSession.php";
//COLLECT POST data
$postcode = $_POST['postcode'];
$postcode = strip_tags($postcode);
$postcode = strtoupper($postcode);
$price = $_POST['price'];
$price = strip_tags($price);
$branch = $_POST['branch'];
$branch = strip_tags($branch);
$bedrooms = $_POST['bedrooms'];
$bedrooms = strip_tags($bedrooms);
$address1 = $_POST['address1'];
$address1 = strip_tags($address1);
$address2 = $_POST['address2'];
$address2 = strip_tags($address2);
$address3 = $_POST['address3'];
$address3 = strip_tags($address3);
$agentDescription = $_POST['agentDescription'];
$agentDescription = strip_tags($agentDescription);
//$propWeek = $_POST['propWeek'];
//$propWeek = strip_tags($propWeek);
$Propertyid = $_POST['Propertyid'];
$Propertyid = strip_tags($Propertyid);
$img = $_FILES['img']['name'];
$img = strip_tags($img);
$imgFullPath = $_POST['img'];
$imgFullPath = strip_tags($imgFullPath);
//Form Error Indicators
//Collect GET vars
$message = $_GET['message'];
//$message = strip_tags($message);
$postcodeError = $_GET['postcodeError'];
$postcodeError = strip_tags($postcodeError);
$priceError = $_GET['priceError'];
$priceError = strip_tags($priceError);
$branchError = $_GET['branchError'];
$branchError = strip_tags($branchError);
$bedroomsError = $_GET['bedroomsError'];
$bedroomsError = strip_tags($bedroomsError);
$address1Error = $_GET['address1Error'];
$address1Error = strip_tags($address1Error);
$address2Error = $_GET['address2Error'];
$address2Error = strip_tags($address2Error);
$address3Error = $_GET['address3Error'];
$address3Error = strip_tags($address3Error);
$entranceError = $_GET['entranceError'];
$entranceError = strip_tags($entranceError);
$loungeError = $_GET['loungeError'];
$loungeError = strip_tags($loungeError);
$kitchenError = $_GET['kitchenError'];
$kitchenError = strip_tags($kitchenError);
$bedroom1Error = $_GET['bedroom1Error'];
$bedroom1Error = strip_tags($bedroom1Error);
$bedroom2Error = $_GET['bedroom2Error'];
$bedroom2Error = strip_tags($bedroom2Error);
$bedroom3Error = $_GET['bedroom3Error'];
$bedroom3Error = strip_tags($bedroom3Error);
$bedroom4Error = $_GET['bedroom4Error'];
$bedroom4Error = strip_tags($bedroom4Error);
$bedroom5Error = $_GET['bedroom5Error'];
$bedroom5Error = strip_tags($bedroom5Error);
$bathroomsError = $_GET['bathroomsError'];
$bathroomsError = strip_tags($bathroomsError);
$tenureError = $_GET['tenureError'];
$tenureError = strip_tags($tenureError);
$garageGardensError = $_GET['garageGardensError'];
$garageGardensError = strip_tags($garageGardensError);
$agentDescriptionError = $_GET['agentDescriptionError'];
$agentDescriptionError = strip_tags($agentDescriptionError);
$propWeekError = $_GET['propWeekError'];
$propWeekError = strip_tags($propWeekError);
$statusError = $_GET['statusError'];
$statusError = strip_tags($statusError);
$CreateRecord = $_GET['CreateRecord'];
$CreateRecord = strip_tags($CreateRecord);
//Collect GET data for SAVED data
//$savedData.=
$postcodeSave = $_GET['postcodeSave']; $savedData.= "postcodeSave=$postcode&" ;
$priceSave = $_GET['priceSave']; $savedData.= "priceSave=$price&";
$branchSave = $_GET['branchSave']; $savedData.= "branchSave=$branch&";
$bedroomsSave = $_GET['bedroomsSave']; $savedData.= "bedroomsSave=$bedrooms&";
$address1Save = $_GET['address1Save']; $savedData.= "address1Save=$address1&";
$address2Save = $_GET['address2Save']; $savedData.= "address2Save=$address2&";
$address3Save = $_GET['address3Save']; $savedData.= "address3Save=$address3&";
$entranceSave = $_GET['entranceSave']; $savedData.= "entranceSave=$entrance&";
$loungeSave = $_GET['loungeSave']; $savedData.= "loungeSave=$lounge&";
$kitchenSave = $_GET['kitchenSave']; $savedData.= "kitchenSave=$kitchen&";
$bedroom1Save = $_GET['bedroom1Save']; $savedData.= "bedroom1Save=$bedroom1&";
$bedroom2Save = $_GET['bedroom2Save']; $savedData.= "bedroom2Save=$bedroom2&";
$bedroom3Save = $_GET['bedroom3Save']; $savedData.= "bedroom3Save=$bedroom3&";
$bedroom4Save = $_GET['bedroom4Save']; $savedData.= "bedroom4Save=$bedroom4&";
$bedroom5Save = $_GET['bedroom5Save']; $savedData.= "bedroom5Save=$bedroom5&";
$bathroomsSave = $_GET['bathroomsSave']; $savedData.= "bathroomsSave=$bathrooms&";
$tenureSave = $_GET['tenureSave']; $savedData.= "tenureSave=$tenure&";
$garageGardensSave = $_GET['garageGardensSave']; $savedData.= "garageGardensSave=$garageGardens&";
$agentDescriptionSave = $_GET['agentDescriptionSave']; $savedData.= "agentDescriptionSave=$agentDescription&";
$agentNotesSave = $_GET['agentNotesSave']; $savedData.= "agentNotesSave=$agentNotes&";
$statusSave = $_GET['statusSave']; $savedData.= "statusSave=$status&";
$propWeekSave = $_GET['propWeekSave']; $savedData.= "propWeekSave=$propWeek&";
$agentIDSave = $_GET['agentIDSave']; $savedData.= "agentIDSave=$agentID&";
$imgSave = $_GET['imgSave']; $savedData.= "imgSave=$img&";
//SETUP SELECTION Dropdowns
//Updated 9.11.06
//To Fix issues with two option being display
//Branch
if($CreateRecord==1){
//Check for empty fields and setup css error var
if(!is_numeric($Bedrooms) or !is_numeric($price )){
$message=" Please check if fields Bedrooms and Price are numerics";}
if(empty($postcode)){
//Sets up a css class to indicate the field error on the form
$postcodeError = "postcodeError";
$errorString.= "postcodeError=$postcodeError&";
}
if(empty($price)||(!is_numeric($price))){
//Sets up a css class to indicate the field error on the form
$priceError = "priceError";
$errorString.= "priceError=$priceError&";
}
if(empty($branch)){
//Sets up a css class to indicate the field error on the form
$branchError = "branchError";
$errorString.= "branchError=$branchError&";
}
if(empty($bedrooms )||(!is_numeric($bedrooms))){
//Sets up a css class to indicate the field error on the form
$bedroomsError = "bedroomsError";
$errorString.= "bedroomsError=$bedroomsError&";
}
if(empty($address2)){
//Sets up a css class to indicate the field error on the form
$address2Error = "address2Error";
$errorString.= "address2Error=$address2Error&";
}
if(empty($address3)){
//Sets up a css class to indicate the field error on the form
$address3Error = "address3Error";
$errorString.= "address3Error=$address3Error&";
}
if(empty($agentDescription)){
//Sets up a css class to indicate the field error on the form
$agentDescriptionError = "agentDescriptionError";
$errorString.= "agentDescriptionError=$agentDescriptionError&";
}
//Combine Error Data into one string
$errorString .= $savedData ;
$errorParse .= $errorString ;
//New routine for generating errors -- Uses $errorString to construct the GET vars
if(!is_numeric($bedrooms)||!is_numeric($price)){
header("location: $PHP_SELF?message=$message&$errorParse");
exit();}
if(empty($postcode) || empty($price) || empty($branch) || empty($bedrooms) || empty($address2) || empty($address3) || empty($agentDescription)){
$message= "Please check the form for missing data in hightlighted fields";
header("location: $PHP_SELF?message=$message&$errorParse");
exit();
}
DBConnect();
$Link = mysql_connect($Host, $User, $Password);
$agentID = $_SESSION['userID'];
//-------Routine for Dealing With Property Of Week-------//
//Sets the Flag to NO for all properties if the current property is SET to YES
$Query_propWeek= "SELECT id, propWeek FROM $table1 WHERE propWeek = 'Yes'";
$Result_propWeek = mysql_db_query ($DBName, $Query_propWeek, $Link);
while($Row_propWeek = mysql_fetch_array($Result_propWeek)){
$Row = $Row_propWeek[id] ;
$Query_updatePropWeek = "UPDATE $table1 SET propWeek = 'No' WHERE id = $Row";
if (mysql_db_query ($DBName, $Query_updatePropWeek, $Link)){
//echo "Properties Propweek changed";
}
}
$propWeek = "Yes";
$imgpath = "propertyImages/tmp.jpg";
$imgpath2 = "propertyImages/tmp2.jpg";
$address1 = "notUsed";
$Query = "INSERT INTO $table1 VALUES ('0', '$postcode', '$price', '$branch', '$bedrooms', '$address1', '$address2', '$address3', '$agentDescription', '$propWeek', '$agentID', '$imgpath', '$imgpath2')";
if (mysql_db_query ($DBName, $Query, $Link)){
//Need to copy the img file
//Bug fix on 27.07.07 we were not getting reliable number matches for the img fields
//This new routine is more complex but fixes the bug
//We now need to change to add image routine so that the image matches the id exactly
if(empty($img)){
$img = "none";
$img2 = "none";
}else{
//Peform Select Query To Find THIS record only - It must match exactly
$Query = "SELECT id, propWeek FROM $table1 WHERE propWeek = 'Yes'";
$Result = mysql_db_query ($DBName, $Query, $Link);
$Row = mysql_fetch_array($Result);
$Propertyid = $Row[id];
//Generate the new img paths
$file1 = $Propertyid;
$file2 = $Propertyid;
$file1 = "propertyThumb".$file1 ;
$f = "propertyThumb".$file2 ;
$f = $f.=".jpg";
$fileLarge = "propertyLarge".$file2 ;
$fileLarge = $fileLarge.=".jpg";
$imgpath = "propertyImages/$f";
$imgpath2 = "propertyImages/$fileLarge";
//Peform UPDATE query to add in the new data for the img feilds
$Query2 = "UPDATE $table1 SET img = '$imgpath', img2 = '$imgpath2' WHERE id = $Propertyid";
mysql_db_query ($DBName, $Query2, $Link)or die(mysql_error());
}
copy($_FILES['img']['tmp_name'], "../propertyImages/$fileLarge");
//Handle the image processing in the class
$handle = new upload($_FILES['img']);
if ($handle->uploaded) {
/* $handle->file_new_name_body = $file1;
$handle->file_new_name_ext = 'jpg';
$handle->image_resize = true;
$handle->image_x = 200;
$handle->image_y = 200;
$handle->image_ratio_y = true;
$handle->image_ratio_x = true;
$handle->jpeg_quality = 100; */
/* $handle->image_text = '$title';
$handle->image_text_direction = 'h';
$handle->image_text_color = '#FF0000';
$handle->image_text_percent = 50;
$handle->image_text_font = 4;
$handle->image_text_y = 5;
$handle->image_text_x = 5; */
// $handle->process('../propertyImages');
/*
if ($handle->processed) {
echo 'image resized';
$handle->clean();
} else {
echo 'error : ' . $handle->error;
} */
}
$Query3 = "SELECT MAX(id) FROM $table1";
$Result = mysql_db_query ($DBName, $Query3, $Link);
$Row = mysql_fetch_array($Result);
$new = $Row['MAX(id)'];
$message = "Property Created Successfully! <br /><a href='YourURL../displayPropFullDetails.php?propertySelect=$new target=_blank'><br />Click Here To Review New Property</a>";
header("location: $PHP_SELF?message=$message");
}else{
$message = "Error Creating Property";
header("location: $PHP_SELF?message=$message");
}
mysql_close($Link);
}
?>
<!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" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>SMARTMOVE CMS Lettings and Management Ltd :: Administrator Page</title>
<!--Style Sheet-->
<?php echo $postcode ; ?>
<link href="../mainstyle.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" type="text/css" href="../AdminSmartmove.css" />
<link rel="stylesheet" type="text/css" href="../dataDisplay.css" />
<link rel="Shortcut Icon" href="favicon.ico"/>
<script src="Scripts/AC_RunActiveContent.js" type="text/javascript"></script>
<script src="Scripts/swfobject.js" type="text/javascript"></script></head>
<body>
<!--Main Content Area-->
<div id="content">
<div id="header">
<!--Main Navigation-->
<ul>
<li><span id="button1"><a href="../index.php" title="Click to view Home Page"></a></span></li>
<li><span id="button2"><a href="../about.php" title="Click to view About us Page"></a></span></li>
<li><span id="button3"><a href="../services.php" title="Click to view Services Page"></a></span></li>
<li><span id="button4"><a href="../properties.php" title="Click to view Properties Page"></a></span></li>
<li><span id="button5"><a href="../region.php" title="Click to view Region Page"></a></span></li>
<li><span id="button6"><a href="../contact.php" title="Click to view Contact Page"></a></span></li>
</ul>
<div id="adminLink">
<a href="admin/index.php"><img src="../images/transparent.gif" title="Click to go to Administrator Page" alt="Click to go to Administrator Page" width="10" height="10" border="0" /></a></div>
<div id="emailLink">
<a href="mailto:andrew@smartmove.com"><img src="../images/transparent.gif" title="Click to send email to webmaster@smartmove.com" alt="Click to send email to webmaster@smartmove.com" width="10" height="10" border="0" /></a></div>
<div id="sitemapLink">
<a href="sitemap.php"><img src="../images/transparent.gif" title="Click to view Site Map Page" alt="Click to view Site Map Page" width="10" height="10" border="0" /></a></div>
<!--Close header-->
</div>
<div id="container">
<div id="headerBox">
<div id="adminImage">
<img src="../images/admin_img.jpg" alt="Administrator Access" title="Administrator Access" width="412" height="54" /></div>
<!--Property Search-->
<div id="adminMenu">
<!--to show admin menu-->
<?php include("adminMenu.php"); ?>
<form method="post" action="" id="systemMessage">
<fieldset>
<legend>System Message</legend>
<?php echo $message;?>
</fieldset>
</form>
</div>
<div id="adminText">
<form action="addNewProperty.php?CreateRecord=1" method="post" enctype="multipart/form-data" name="form1" id="genericForm">
<fieldset>
<legend>Add New Property</legend>
<div><label for="Address2">Street</label><input id="address2" name="address2" type="text" class="<?php echo $address2Error ; ?>" value="<?php echo $address2Save ; ?>" /></div>
<div><label for="Address3">Town</label><input id="address3" name="address3" type="text" class="<?php echo $address3Error ; ?>" value="<?php echo $address3Save ; ?>" /></div>
<div><label for="Postcode">Postcode</label><input id="postcode" name="postcode" type="text" size="8" class="<?php echo $postcodeError ; ?>" value="<?php echo $postcodeSave ; ?>" />
</div>
<div><label for="Bedrooms">Bedrooms</label>
<input id="bedrooms" name="bedrooms" type="text" class="<?php echo $bedroomsError ; ?>" value="<?php echo $bedroomsSave ; ?>" size="2" />
</div>
<div><label for="Price">Price</label><input id="price" name="price" type="text" size="8" class="<?php echo $priceError ; ?>" value="<?php echo $priceSave ; ?>" />
</div>
<div>
<label for="branch">Area</label>
<select id="branch" name="branch" size="1" class="branch">
<?php if(empty($branchSave)){
echo"<option selected='selected'>Yarm</option>
<option>Eaglescliffe</option>
<option>Stokesley</option>
<option>Ingleby Barwick</option>
<option>Middlesbrough</option>
<option>Other Villages</option></select> ";
}else{
$j=0;
$Town = Array('Yarm','Eaglescliffe','Stokesley','Ingleby Barwick','Middlesbrough','Other Villages');
echo "<option selected='selected'>".$branchSave."</option>";
$j=0;
while($j<=5){
if($branchSave==$Town[$j]){
$j=$j+1;
}else{
$name=$Town[$j];
echo "<option>".$name."</option>";
$j=$j+1;
}
}
echo"</select>";
}
?>
</div>
<div><label for="agentDescription">Agent Description</label>
<textarea id="agentDescription" name="agentDescription" class="<?php echo $agentDescriptionError ; ?>"><?php echo $agentDescriptionSave ; ?></textarea>
</div>
<div><label for="file">Property Image</label>
<input id="img" name="img" type="file" value="<?php echo $imgSave ; ?>" /></div>
<div class="submit"><input name="Submit" type="Submit" class="btn" value="Add Property" /></div>
</fieldset>
</form>
</div>
<!--Info Text-->
<!--Contact Text-->
<!--Footer Info-->
</div>
</div>
</div>
<div id="footer">
<!--CSS Rollover Image Hack-->
<div class="cssRolloverImageHack_1"></div>
<div class="cssRolloverImageHack_2"></div>
<div class="cssRolloverImageHack_3"></div>
<div class="cssRolloverImageHack_4"></div>
<div class="cssRolloverImageHack_5"></div>
<div class="cssRolloverImageHack_6"></div>
<!--end footer-->
</div>
</body>
</html>
R4f
Messages postés
441
Date d'inscription
dimanche 13 janvier 2008
Statut
Membre
Dernière intervention
5 mai 2008
62
18 avril 2008 à 00:45
18 avril 2008 à 00:45
Bon, en l'atat, je ne peux pas prendre ton code et le tester car il me manque des fichier inclus.
Ce que je vois comme améliorations pour la taille, la lisibilité et la maintenabilité de ton code :
ne pas faire 40 fois les mêmes opérations sur des variables différentes, mais faire un tableau contenant les clés du tableau $_GET ou $_POST à traiter.
Exemple, remplacer :
Par
Et ainsi de suite.
Autre truc : toujours utiliser «mysql_escape_strings» pour les chaînes de caractères à mettre dans les requêtes à la base :
Donc :
devient :
Sinon, après une commande de redirection : header("location: $PHP_SELF?message=$message");, toujours ajouter un exit(); (rien ne sert de continuer le script, le client est déjà parti !).
La gestion du <select id="branch" name="branch" size="1" class="branch"> n'est pas très élégante. On pourrait remplacer :
Par :
Au lieu de passer les chaînes de message telles quelles en GET, les mettre en session et faire attention pour les redirections (Location au lieu de location même si généralement ça passe) :
Par exemple :
Mais en fait, pourquoi se rediriger sur soi-même ?
Il faudrait structurer la page différemment de manière à détecter plus tôt ce types d'erreurs...
Et puis au lieu d'imbriquer 2 requêtes, en faire une puis une autre et c'est tout :
Deviendrait :
Bon, tout ce que j'ai suggéré ici est a priori bon, mais je n'ai pas pu faire l'essai. Il y aurait encore pas mal de trucs à cleaner, notamment pour la gestion des messages d'erreurs...
A mon avis, ce problème d'image est l'arbre qui cache la forêt. Ton code est trop touffu inutilement et difficilement debuggable/modifiable/comprehensible.
Si ton truc tourne lorsque tu l'extrais de son contexte (c'est ce que j'ai cru comprendre) alors c'est que le pb vient d'ailleurs...
En espérant que ça serve.
Raph
Ce que je vois comme améliorations pour la taille, la lisibilité et la maintenabilité de ton code :
ne pas faire 40 fois les mêmes opérations sur des variables différentes, mais faire un tableau contenant les clés du tableau $_GET ou $_POST à traiter.
Exemple, remplacer :
$postcode = $_POST['postcode']; $postcode = strip_tags($postcode); $postcode = strtoupper($postcode); $price = $_POST['price']; $price = strip_tags($price); $branch = $_POST['branch']; $branch = strip_tags($branch); $bedrooms = $_POST['bedrooms']; $bedrooms = strip_tags($bedrooms); $address1 = $_POST['address1']; $address1 = strip_tags($address1); $address2 = $_POST['address2']; $address2 = strip_tags($address2); $address3 = $_POST['address3']; $address3 = strip_tags($address3);
Par
$post_vars = array('postcode', 'price', 'bedrooms'.....); $variable = array(); foreach ($post_vars as $cle => $val) { $variable[$cle] = strip_tags($val); } $variable['postcode'] = strtoupper($variable['postcode']);
Et ainsi de suite.
Autre truc : toujours utiliser «mysql_escape_strings» pour les chaînes de caractères à mettre dans les requêtes à la base :
Donc :
$Query = "INSERT INTO $table1 VALUES ('0', '$postcode', '$price', '$branch', '$bedrooms', '$address1', '$address2', '$address3', '$agentDescription', '$propWeek', '$agentID', '$imgpath', '$imgpath2')";
devient :
$Query = "INSERT INTO $table1 VALUES ('0', '".mysql_escape_strings('$postcode')."', '".mysql_escape_strings('$price')."', '".mysql_escape_strings('$branch')."', '".mysql_escape_strings('$bedrooms')."', '".mysql_escape_strings('$address1')."', '".mysql_escape_strings('$address2')."', '".mysql_escape_strings('$address3')."', '".mysql_escape_strings('$agentDescription')."', '".mysql_escape_strings('$propWeek')."', '".mysql_escape_strings('$agentID')."', '".mysql_escape_strings('$imgpath')."', '".mysql_escape_strings('$imgpath2')."')";
Sinon, après une commande de redirection : header("location: $PHP_SELF?message=$message");, toujours ajouter un exit(); (rien ne sert de continuer le script, le client est déjà parti !).
La gestion du <select id="branch" name="branch" size="1" class="branch"> n'est pas très élégante. On pourrait remplacer :
<?php if(empty($branchSave)){ echo"<option selected='selected'>Yarm</option> <option>Eaglescliffe</option> <option>Stokesley</option> <option>Ingleby Barwick</option> <option>Middlesbrough</option> <option>Other Villages</option></select> "; }else{ $j=0; $Town = Array('Yarm','Eaglescliffe','Stokesley','Ingleby Barwick','Middlesbrough','Other Villages'); echo "<option selected='selected'>".$branchSave."</option>"; $j=0; while($j<=5){ if($branchSave==$Town[$j]){ $j=$j+1; }else{ $name=$Town[$j]; echo "<option>".$name."</option>"; $j=$j+1; } } ?>
Par :
<?php $Town = Array('Yarm','Eaglescliffe','Stokesley','Ingleby Barwick','Middlesbrough','Other Villages'); $chaine_option = ''. foreach ($Town as $laville) { if ($laville == $branchSave) $selected = ' selected="selected"'; else $selected = ''; $laville = htmlentities($laville); $chaine_option .= "<option$selected>$laville</option>\n" } ?>
Au lieu de passer les chaînes de message telles quelles en GET, les mettre en session et faire attention pour les redirections (Location au lieu de location même si généralement ça passe) :
$message= "Please check the form for missing data in hightlighted fields"; header("location: $PHP_SELF?message=$message&$errorParse");
Par exemple :
$_SESSION['message'] = "Please check the form for missing data in hightlighted fields"; header("Location: $PHP_SELF");
Mais en fait, pourquoi se rediriger sur soi-même ?
Il faudrait structurer la page différemment de manière à détecter plus tôt ce types d'erreurs...
Et puis au lieu d'imbriquer 2 requêtes, en faire une puis une autre et c'est tout :
//Sets the Flag to NO for all properties if the current property is SET to YES $Query_propWeek= "SELECT id, propWeek FROM $table1 WHERE propWeek = 'Yes'"; $Result_propWeek = mysql_db_query ($DBName, $Query_propWeek, $Link); while($Row_propWeek = mysql_fetch_array($Result_propWeek)){ $Row = $Row_propWeek[id] ; $Query_updatePropWeek = "UPDATE $table1 SET propWeek = 'No' WHERE id = $Row"; if (mysql_db_query ($DBName, $Query_updatePropWeek, $Link)){ //echo "Properties Propweek changed"; }
Deviendrait :
//Sets the Flag to NO for all properties if the current property is SET to YES $Query_propWeek= "SELECT id, propWeek FROM $table1 WHERE propWeek = 'Yes'"; $Result_propWeek = mysql_db_query ($DBName, $Query_propWeek, $Link); $Row = array(); while($Row_propWeek = mysql_fetch_array($Result_propWeek)){ $Row[] = $Row_propWeek[id] ; } $Query_updatePropWeek = "UPDATE $table1 SET propWeek = 'No' WHERE id = ". implode(' or id = ', $Row); if (mysql_db_query ($DBName, $Query_updatePropWeek, $Link)){ //echo "Properties Propweek changed";
Bon, tout ce que j'ai suggéré ici est a priori bon, mais je n'ai pas pu faire l'essai. Il y aurait encore pas mal de trucs à cleaner, notamment pour la gestion des messages d'erreurs...
A mon avis, ce problème d'image est l'arbre qui cache la forêt. Ton code est trop touffu inutilement et difficilement debuggable/modifiable/comprehensible.
Si ton truc tourne lorsque tu l'extrais de son contexte (c'est ce que j'ai cru comprendre) alors c'est que le pb vient d'ailleurs...
En espérant que ça serve.
Raph
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre question
G4uthier
Messages postés
131
Date d'inscription
dimanche 2 décembre 2007
Statut
Membre
Dernière intervention
23 juillet 2009
7
18 avril 2008 à 00:36
18 avril 2008 à 00:36
oui il est en haut de ma page c'est qu une partie de mon code ca.
G4uthier
Messages postés
131
Date d'inscription
dimanche 2 décembre 2007
Statut
Membre
Dernière intervention
23 juillet 2009
7
18 avril 2008 à 00:48
18 avril 2008 à 00:48
merci raph d'avoir pris du temps pour moi je vais tester ça demain je te dis quoi quand j'ai "cleané" mon code.
Merci à bientot ;)
Merci à bientot ;)
G4uthier
Messages postés
131
Date d'inscription
dimanche 2 décembre 2007
Statut
Membre
Dernière intervention
23 juillet 2009
7
18 avril 2008 à 01:35
18 avril 2008 à 01:35
Par contre, pour ta premeire methode je dois toujours effectuer les $_POST les uns apres les autres. ton tableau sert juste à rajouter les strip_tags? c'est bien ca?
R4f
Messages postés
441
Date d'inscription
dimanche 13 janvier 2008
Statut
Membre
Dernière intervention
5 mai 2008
62
18 avril 2008 à 10:46
18 avril 2008 à 10:46
Disons que passer par des variables indépendantes '$postcode' pour $_POST['postcode'] ne sert pas beaucoup. Dans mon exemple, je préférerais utiliser $variable['postcode'] plutôt que de l'affecter à '$postcode'.
Les boucles sont à utiliser à plein d'autres endroits:
- Par exemple, là où tu collestes les variables GET vers //Collect GET vars
- Pour constituer ta vairable $savedData
- et peut-être d'autres
De manière générale, lorsque tu fais 2 fois la même chose tu peux te demander si
- tu ne peux pas mettre ce traitement dans une boucle en passant par un tableau
- tu ne peux pas faire une fonction (dans ton code, ça manque)
Raph
Les boucles sont à utiliser à plein d'autres endroits:
- Par exemple, là où tu collestes les variables GET vers //Collect GET vars
- Pour constituer ta vairable $savedData
- et peut-être d'autres
De manière générale, lorsque tu fais 2 fois la même chose tu peux te demander si
- tu ne peux pas mettre ce traitement dans une boucle en passant par un tableau
- tu ne peux pas faire une fonction (dans ton code, ça manque)
Raph
G4uthier
Messages postés
131
Date d'inscription
dimanche 2 décembre 2007
Statut
Membre
Dernière intervention
23 juillet 2009
7
18 avril 2008 à 11:25
18 avril 2008 à 11:25
$post_vars = array('postcode', 'price', 'bedrooms');
$variable = array();
foreach ($post_vars as $cle => $_POST[$cle]) {
$variable[$cle] = strip_tags($_POST[$cle]);
}
echo $variable['postcode'];
echo $variable['price'];
echo $variable['bedrooms'];
c'est normal que ca n'affiche que le postcode?
j'utilise pas le foreach d'habitude c'est la premiere fois donc je tatonne.... désolé
$variable = array();
foreach ($post_vars as $cle => $_POST[$cle]) {
$variable[$cle] = strip_tags($_POST[$cle]);
}
echo $variable['postcode'];
echo $variable['price'];
echo $variable['bedrooms'];
c'est normal que ca n'affiche que le postcode?
j'utilise pas le foreach d'habitude c'est la premiere fois donc je tatonne.... désolé
R4f
Messages postés
441
Date d'inscription
dimanche 13 janvier 2008
Statut
Membre
Dernière intervention
5 mai 2008
62
18 avril 2008 à 11:59
18 avril 2008 à 11:59
C'est pas tout à fait ça mais presque :
Là, ça devrait marcher. HTTP_POST_VARS c'est de l'ancien temps ;-)
Raph
foreach ($_POST as $cle => $valeur) { $variable[$cle] = strip_tags($valeur); }
Là, ça devrait marcher. HTTP_POST_VARS c'est de l'ancien temps ;-)
Raph
G4uthier
Messages postés
131
Date d'inscription
dimanche 2 décembre 2007
Statut
Membre
Dernière intervention
23 juillet 2009
7
18 avril 2008 à 17:23
18 avril 2008 à 17:23
Voila j'ai debroussailler le code . mais la fonction mysql_escape_string mais ca me desactive les caracteres speciaux pour ma requete donc je me retrrouve avec des tuc du genre ca dans ma base:
$formValu 0 $formValue["branch"] 0 $address1 $formValue["address2"] ..... i
Il ne me rentre plus mes valeurs dans la base.
session_start();
include "../common.php";
include('class.upload.php');
//Check if the user has logged in
include "checkLoginSession.php";
//COLLECT POST data
$formValue=array();
foreach ($_POST as $key => $value) {
$formValue[$key] = strip_tags($value);
}
//SETUP SELECTION Dropdowns
//Updated 9.11.06
//To Fix issues with two option being display
//Branch
//if(isset($_POST['Submit'])){
//Check for empty fields and setup css error var
if($formValue['address2']==""){;
$message="Please fill in the field street";
$address2Error="address2Error";
}else{
if($formValue['address3']==""){
$message="Please fill in the field Town";
$address3Error="address3Error";}
else{
if($formValue['postcode']==""){
$message="Please fill in the field Postcode";
$postcodeError="postcodeError";}
else{
if($formValue['bedrooms']==""){
$message="Please fill in the field Bedrooms";
$bedroomsError="bedroomsError";}
else{
if($formValue['price']==""){
$message="Please fill in the field Price";
$priceError="priceError";}
else{
if($formValue['agentDescription']==""){
$message="Please fill in the field Agent Description";
$agentDescriptionError="agentDescriptionError";
}else{
DBConnect();
$Link = mysql_connect($Host, $User, $Password);
$agentID = $_SESSION['userID'];
//-------Routine for Dealing With Property Of Week-------//
//Sets the Flag to NO for all properties if the current property is SET to YES
$Query_propWeek= "SELECT id, propWeek FROM $table1 WHERE propWeek = 'Yes'";
$Result_propWeek = mysql_db_query ($DBName, $Query_propWeek, $Link);
$Row = array();
while($Row_propWeek = mysql_fetch_array($Result_propWeek)){
$Row[] = $Row_propWeek[id] ;
}
$Query_updatePropWeek = "UPDATE $table1 SET propWeek = 'No' WHERE id = ". implode(' or id = ', $Row);
if (mysql_db_query ($DBName, $Query_updatePropWeek, $Link)){
}
$propWeek = "Yes";
$imgpath = "propertyImages/tmp.jpg";
$imgpath2 = "propertyImages/tmp2.jpg";
$address1 = "notUsed";
$Query = "INSERT INTO $table1 VALUES ('0', '".mysql_escape_string('$formValue["postcode"]')."','".mysql_escape_string('$formValue["price"]')."', '".mysql_escape_string('$formValue["branch"]')."', '".mysql_escape_string('$formValue["bedrooms"]')."',
'".mysql_escape_string('$address1')."', '".mysql_escape_string('$formValue["address2"]')."','".mysql_escape_string('$formValue["address3"]')."', '".mysql_escape_string('$formValue["agentDescription"]')."','".mysql_escape_string('$propWeek')."',
'".mysql_escape_string('$agentID')."', '".mysql_escape_string('$imgpath')."', '".mysql_escape_string('$imgpath2')."')";
echo $Query;
if (mysql_db_query ($DBName, $Query, $Link)){
//Need to copy the img file
//Bug fix on 27.07.07 we were not getting reliable number matches for the img fields
//This new routine is more complex but fixes the bug
//We now need to change to add image routine so that the image matches the id exactly
if(empty($formValue['img'])){
$img = "none";
$img2 = "none";
}else{
//Peform Select Query To Find THIS record only - It must match exactly
$Query = "SELECT id, propWeek FROM $table1 WHERE propWeek = 'Yes'";
$Result = mysql_db_query ($DBName, $Query, $Link);
$Row = mysql_fetch_array($Result);
$Propertyid = $Row[id];
//Generate the new img paths
$file1 = $Propertyid;
$file2 = $Propertyid;
$file1 = "propertyThumb".$file1 ;
$f = "propertyThumb".$file2 ;
$f = $f.=".jpg";
$fileLarge = "propertyLarge".$file2 ;
$fileLarge = $fileLarge.=".jpg";
$imgpath = "propertyImages/$f";
$imgpath2 = "propertyImages/$fileLarge";
//Peform UPDATE query to add in the new data for the img fields
$Query2 = "UPDATE $table1 SET img = '$imgpath', img2 = '$imgpath2' WHERE id = $Propertyid";
mysql_db_query ($DBName, $Query2, $Link)or die(mysql_error());
}
copy($_FILES['img']['tmp_name'], "../propertyImages/$fileLarge");
//Handle the image processing in the class
$handle = new upload($_FILES['img']);
if ($handle->uploaded) {
/* $handle->file_new_name_body = $file1;
$handle->file_new_name_ext = 'jpg';
$handle->image_resize = true;
$handle->image_x = 200;
$handle->image_y = 200;
$handle->image_ratio_y = true;
$handle->image_ratio_x = true;
$handle->jpeg_quality = 100; */
/* $handle->image_text = '$title';
$handle->image_text_direction = 'h';
$handle->image_text_color = '#FF0000';
$handle->image_text_percent = 50;
$handle->image_text_font = 4;
$handle->image_text_y = 5;
$handle->image_text_x = 5; */
// $handle->process('../propertyImages');
/*
if ($handle->processed) {
echo 'image resized';
$handle->clean();
} else {
echo 'error : ' . $handle->error;
} */
$Query3 = "SELECT MAX(id) FROM $table1";
$Result = mysql_db_query ($DBName, $Query3, $Link);
$Row = mysql_fetch_array($Result);
$new = $Row['MAX(id)'];
$message = "Property Created Successfully! <br /><a href='YourURL../displayPropFullDetails.php?propertySelect=$new target=_blank'><br />Click Here To Review New Property</a>";
}else{
$message = "Error Creating Property";
}
mysql_close($Link);
}
}
}
}
}
}
}
//}
$formValu 0 $formValue["branch"] 0 $address1 $formValue["address2"] ..... i
Il ne me rentre plus mes valeurs dans la base.
session_start();
include "../common.php";
include('class.upload.php');
//Check if the user has logged in
include "checkLoginSession.php";
//COLLECT POST data
$formValue=array();
foreach ($_POST as $key => $value) {
$formValue[$key] = strip_tags($value);
}
//SETUP SELECTION Dropdowns
//Updated 9.11.06
//To Fix issues with two option being display
//Branch
//if(isset($_POST['Submit'])){
//Check for empty fields and setup css error var
if($formValue['address2']==""){;
$message="Please fill in the field street";
$address2Error="address2Error";
}else{
if($formValue['address3']==""){
$message="Please fill in the field Town";
$address3Error="address3Error";}
else{
if($formValue['postcode']==""){
$message="Please fill in the field Postcode";
$postcodeError="postcodeError";}
else{
if($formValue['bedrooms']==""){
$message="Please fill in the field Bedrooms";
$bedroomsError="bedroomsError";}
else{
if($formValue['price']==""){
$message="Please fill in the field Price";
$priceError="priceError";}
else{
if($formValue['agentDescription']==""){
$message="Please fill in the field Agent Description";
$agentDescriptionError="agentDescriptionError";
}else{
DBConnect();
$Link = mysql_connect($Host, $User, $Password);
$agentID = $_SESSION['userID'];
//-------Routine for Dealing With Property Of Week-------//
//Sets the Flag to NO for all properties if the current property is SET to YES
$Query_propWeek= "SELECT id, propWeek FROM $table1 WHERE propWeek = 'Yes'";
$Result_propWeek = mysql_db_query ($DBName, $Query_propWeek, $Link);
$Row = array();
while($Row_propWeek = mysql_fetch_array($Result_propWeek)){
$Row[] = $Row_propWeek[id] ;
}
$Query_updatePropWeek = "UPDATE $table1 SET propWeek = 'No' WHERE id = ". implode(' or id = ', $Row);
if (mysql_db_query ($DBName, $Query_updatePropWeek, $Link)){
}
$propWeek = "Yes";
$imgpath = "propertyImages/tmp.jpg";
$imgpath2 = "propertyImages/tmp2.jpg";
$address1 = "notUsed";
$Query = "INSERT INTO $table1 VALUES ('0', '".mysql_escape_string('$formValue["postcode"]')."','".mysql_escape_string('$formValue["price"]')."', '".mysql_escape_string('$formValue["branch"]')."', '".mysql_escape_string('$formValue["bedrooms"]')."',
'".mysql_escape_string('$address1')."', '".mysql_escape_string('$formValue["address2"]')."','".mysql_escape_string('$formValue["address3"]')."', '".mysql_escape_string('$formValue["agentDescription"]')."','".mysql_escape_string('$propWeek')."',
'".mysql_escape_string('$agentID')."', '".mysql_escape_string('$imgpath')."', '".mysql_escape_string('$imgpath2')."')";
echo $Query;
if (mysql_db_query ($DBName, $Query, $Link)){
//Need to copy the img file
//Bug fix on 27.07.07 we were not getting reliable number matches for the img fields
//This new routine is more complex but fixes the bug
//We now need to change to add image routine so that the image matches the id exactly
if(empty($formValue['img'])){
$img = "none";
$img2 = "none";
}else{
//Peform Select Query To Find THIS record only - It must match exactly
$Query = "SELECT id, propWeek FROM $table1 WHERE propWeek = 'Yes'";
$Result = mysql_db_query ($DBName, $Query, $Link);
$Row = mysql_fetch_array($Result);
$Propertyid = $Row[id];
//Generate the new img paths
$file1 = $Propertyid;
$file2 = $Propertyid;
$file1 = "propertyThumb".$file1 ;
$f = "propertyThumb".$file2 ;
$f = $f.=".jpg";
$fileLarge = "propertyLarge".$file2 ;
$fileLarge = $fileLarge.=".jpg";
$imgpath = "propertyImages/$f";
$imgpath2 = "propertyImages/$fileLarge";
//Peform UPDATE query to add in the new data for the img fields
$Query2 = "UPDATE $table1 SET img = '$imgpath', img2 = '$imgpath2' WHERE id = $Propertyid";
mysql_db_query ($DBName, $Query2, $Link)or die(mysql_error());
}
copy($_FILES['img']['tmp_name'], "../propertyImages/$fileLarge");
//Handle the image processing in the class
$handle = new upload($_FILES['img']);
if ($handle->uploaded) {
/* $handle->file_new_name_body = $file1;
$handle->file_new_name_ext = 'jpg';
$handle->image_resize = true;
$handle->image_x = 200;
$handle->image_y = 200;
$handle->image_ratio_y = true;
$handle->image_ratio_x = true;
$handle->jpeg_quality = 100; */
/* $handle->image_text = '$title';
$handle->image_text_direction = 'h';
$handle->image_text_color = '#FF0000';
$handle->image_text_percent = 50;
$handle->image_text_font = 4;
$handle->image_text_y = 5;
$handle->image_text_x = 5; */
// $handle->process('../propertyImages');
/*
if ($handle->processed) {
echo 'image resized';
$handle->clean();
} else {
echo 'error : ' . $handle->error;
} */
$Query3 = "SELECT MAX(id) FROM $table1";
$Result = mysql_db_query ($DBName, $Query3, $Link);
$Row = mysql_fetch_array($Result);
$new = $Row['MAX(id)'];
$message = "Property Created Successfully! <br /><a href='YourURL../displayPropFullDetails.php?propertySelect=$new target=_blank'><br />Click Here To Review New Property</a>";
}else{
$message = "Error Creating Property";
}
mysql_close($Link);
}
}
}
}
}
}
}
//}
R4f
Messages postés
441
Date d'inscription
dimanche 13 janvier 2008
Statut
Membre
Dernière intervention
5 mai 2008
62
18 avril 2008 à 17:42
18 avril 2008 à 17:42
Ah oui, je m'étais trompé, il ne faut pas mettre entre guillemets :
Là, ça devrait aller mieux...
Tu sais, ton code, tu devrais le mettre entre <code> et </code> , ça serait plus lisible que juste collé comme ça.
Raph
mysql_escape_string($formValue["postcode"])
Là, ça devrait aller mieux...
Tu sais, ton code, tu devrais le mettre entre <code> et </code> , ça serait plus lisible que juste collé comme ça.
Raph
G4uthier
Messages postés
131
Date d'inscription
dimanche 2 décembre 2007
Statut
Membre
Dernière intervention
23 juillet 2009
7
18 avril 2008 à 17:46
18 avril 2008 à 17:46
yeah that's good ;)
R4f
Messages postés
441
Date d'inscription
dimanche 13 janvier 2008
Statut
Membre
Dernière intervention
5 mai 2008
62
18 avril 2008 à 17:49
18 avril 2008 à 17:49
Bon et maintenant ?
G4uthier
Messages postés
131
Date d'inscription
dimanche 2 décembre 2007
Statut
Membre
Dernière intervention
23 juillet 2009
7
18 avril 2008 à 17:58
18 avril 2008 à 17:58
je n'ai plus de page blanche ije retourne effectivement bien sur le formulaire. mais la photo dans mon dossier n'est pas redimensionnée
G4uthier
Messages postés
131
Date d'inscription
dimanche 2 décembre 2007
Statut
Membre
Dernière intervention
23 juillet 2009
7
18 avril 2008 à 17:58
18 avril 2008 à 17:58
je n'ai plus de page blanche ije retourne effectivement bien sur le formulaire. mais la photo dans mon dossier n'est pas redimensionnée
R4f
Messages postés
441
Date d'inscription
dimanche 13 janvier 2008
Statut
Membre
Dernière intervention
5 mai 2008
62
18 avril 2008 à 18:27
18 avril 2008 à 18:27
Ok, alors tu peux me filer le code qui marche maintenant ? (n'oublie pas <code> et </code>)
Raph
Raph
G4uthier
Messages postés
131
Date d'inscription
dimanche 2 décembre 2007
Statut
Membre
Dernière intervention
23 juillet 2009
7
18 avril 2008 à 18:38
18 avril 2008 à 18:38
<?php
session_start();
include "../common.php";
include('class.upload.php');
//Check if the user has logged in
include "checkLoginSession.php";
//COLLECT POST data
$formValue=array();
foreach ($_POST as $key => $value) {
$formValue[$key] = strip_tags($value);
}
//SETUP SELECTION Dropdowns
//Updated 9.11.06
//To Fix issues with two option being display
//Branch
//if(isset($_POST['Submit'])){
//Check for empty fields and setup css error var
if($formValue['address2']==""){;
$message="Please fill in the field street";
$address2Error="address2Error";
}else{
if($formValue['address3']==""){
$message="Please fill in the field Town";
$address3Error="address3Error";}
else{
if($formValue['postcode']==""){
$message="Please fill in the field Postcode";
$postcodeError="postcodeError";}
else{
if($formValue['bedrooms']==""){
$message="Please fill in the field Bedrooms";
$bedroomsError="bedroomsError";}
else{
if($formValue['price']==""){
$message="Please fill in the field Price";
$priceError="priceError";}
else{
if($formValue['agentDescription']==""){
$message="Please fill in the field Agent Description";
$agentDescriptionError="agentDescriptionError";
}else{
DBConnect();
$Link = mysql_connect($Host, $User, $Password);
$agentID = $_SESSION['userID'];
//-------Routine for Dealing With Property Of Week-------//
//Sets the Flag to NO for all properties if the current property is SET to YES
$Query_propWeek= "SELECT id, propWeek FROM $table1 WHERE propWeek = 'Yes'";
$Result_propWeek = mysql_db_query ($DBName, $Query_propWeek, $Link);
$Row = array();
while($Row_propWeek = mysql_fetch_array($Result_propWeek)){
$Row[] = $Row_propWeek[id] ;
}
$Query_updatePropWeek = "UPDATE $table1 SET propWeek = 'No' WHERE id = ". implode(' or id = ', $Row);
if (mysql_db_query ($DBName, $Query_updatePropWeek, $Link)){
}
$propWeek = "Yes";
$imgpath = "propertyImages/tmp.jpg";
$imgpath2 = "propertyImages/tmp2.jpg";
$address1 = "notUsed";
$Query = "INSERT INTO $table1 VALUES ('0', '".mysql_escape_string($formValue['postcode'])."','".mysql_escape_string($formValue["price"])."', '".mysql_escape_string($formValue["branch"])."', '".mysql_escape_string($formValue["bedrooms"])."',
'".mysql_escape_string($address1)."', '".mysql_escape_string($formValue["address2"])."','".mysql_escape_string($formValue["address3"])."', '".mysql_escape_string($formValue["agentDescription"])."','".mysql_escape_string($propWeek)."',
'".mysql_escape_string($agentID)."', '".mysql_escape_string($imgpath)."', '".mysql_escape_string($imgpath2)."')";
echo $Query;
if (mysql_db_query ($DBName, $Query, $Link)){
//Need to copy the img file
//Bug fix on 27.07.07 we were not getting reliable number matches for the img fields
//This new routine is more complex but fixes the bug
//We now need to change to add image routine so that the image matches the id exactly
if(empty($formValue['img'])){
$img = "none";
$img2 = "none";
}else{
//Peform Select Query To Find THIS record only - It must match exactly
$Query = "SELECT id, propWeek FROM $table1 WHERE propWeek = 'Yes'";
$Result = mysql_db_query ($DBName, $Query, $Link);
$Row = mysql_fetch_array($Result);
$Propertyid = $Row[id];
//Generate the new img paths
$file1 = $Propertyid;
$file2 = $Propertyid;
$file1 = "propertyThumb".$file1 ;
$f = "propertyThumb".$file2 ;
$f = $f.=".jpg";
$fileLarge = "propertyLarge".$file2 ;
$fileLarge = $fileLarge.=".jpg";
$imgpath = "propertyImages/$f";
$imgpath2 = "propertyImages/$fileLarge";
//Peform UPDATE query to add in the new data for the img fields
$Query2 = "UPDATE $table1 SET img = '$imgpath', img2 = '$imgpath2' WHERE id = $Propertyid";
mysql_db_query ($DBName, $Query2, $Link)or die(mysql_error());
}
copy($_FILES['img']['tmp_name'], "../propertyImages/$fileLarge");
//Handle the image processing in the class
$handle = new upload($_FILES['img']);
if ($handle->uploaded) {
$handle->file_new_name_body = $file1;
$handle->file_new_name_ext = 'jpg';
$handle->image_resize = true;
$handle->image_x = 200;
$handle->image_y = 200;
$handle->image_ratio_y = true;
$handle->image_ratio_x = true;
$handle->jpeg_quality = 100;
/* $handle->image_text = '$title';
$handle->image_text_direction = 'h';
$handle->image_text_color = '#FF0000';
$handle->image_text_percent = 50;
$handle->image_text_font = 4;
$handle->image_text_y = 5;
$handle->image_text_x = 5; */
$handle->process('../propertyImages');
if ($handle->processed) {
echo 'image resized';
$handle->clean();
} else {
echo 'error : ' . $handle->error;
}
$Query3 = "SELECT MAX(id) FROM $table1";
$Result = mysql_db_query ($DBName, $Query3, $Link);
$Row = mysql_fetch_array($Result);
$new = $Row['MAX(id)'];
$message = "Property Created Successfully! <br /><a href='YourURL../displayPropFullDetails.php?propertySelect=$new target=_blank'><br />Click Here To Review New Property</a>";
}else{
$message = "Error Creating Property";
}
mysql_close($Link);
}
}
}
}
}
}
}
//}
?>
<!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" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>SMARTMOVE CMS Lettings and Management Ltd :: Administrator Page</title>
<!--Style Sheet-->
<?php echo $postcode ; ?>
<link href="../mainstyle.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" type="text/css" href="../AdminSmartmove.css" />
<link rel="stylesheet" type="text/css" href="../dataDisplay.css" />
<link rel="Shortcut Icon" href="favicon.ico"/>
<script src="Scripts/AC_RunActiveContent.js" type="text/javascript"></script>
<script src="Scripts/swfobject.js" type="text/javascript"></script></head>
<body>
<!--Main Content Area-->
<div id="content">
<div id="header">
<!--Main Navigation-->
<ul>
<li><span id="button1"><a href="../index.php" title="Click to view Home Page"></a></span></li>
<li><span id="button2"><a href="../about.php" title="Click to view About us Page"></a></span></li>
<li><span id="button3"><a href="../services.php" title="Click to view Services Page"></a></span></li>
<li><span id="button4"><a href="../properties.php" title="Click to view Properties Page"></a></span></li>
<li><span id="button5"><a href="../region.php" title="Click to view Region Page"></a></span></li>
<li><span id="button6"><a href="../contact.php" title="Click to view Contact Page"></a></span></li>
</ul>
<div id="adminLink">
<a href="admin/index.php"><img src="../images/transparent.gif" title="Click to go to Administrator Page" alt="Click to go to Administrator Page" width="10" height="10" border="0" /></a></div>
<div id="emailLink">
<a href="mailto:andrew@smartmove.com"><img src="../images/transparent.gif" title="Click to send email to webmaster@smartmove.com" alt="Click to send email to webmaster@smartmove.com" width="10" height="10" border="0" /></a></div>
<div id="sitemapLink">
<a href="sitemap.php"><img src="../images/transparent.gif" title="Click to view Site Map Page" alt="Click to view Site Map Page" width="10" height="10" border="0" /></a></div>
<!--Close header-->
</div>
<div id="container">
<div id="headerBox">
<div id="adminImage">
<img src="../images/admin_img.jpg" alt="Administrator Access" title="Administrator Access" width="412" height="54" /></div>
<!--Property Search-->
<div id="adminMenu">
<!--to show admin menu-->
<?php include("adminMenu.php"); ?>
<form method="post" action="" id="systemMessage">
<fieldset>
<legend>System Message</legend>
<?php echo $message;?>
</fieldset>
</form>
</div>
<div id="adminText">
<form action="<?php $_SERVER['PHPSELF']?>" method="post" enctype="multipart/form-data" name="form1" id="genericForm">
<fieldset>
<legend>Add New Property</legend>
<div><label for="Address2">Street</label><input id="address2" name="address2" type="text" class="<?php echo $address2Error ; ?>" value="<?php echo $formValue['address2']; ?>" /></div>
<div><label for="Address3">Town</label><input id="address3" name="address3" type="text" class="<?php echo $address3Error ; ?>" value="<?php echo $formValue['address3'] ; ?>" /></div>
<div><label for="Postcode">Postcode</label><input id="postcode" name="postcode" type="text" size="8" class="<?php echo $postcodeError ; ?>" value="<?php echo $formValue['postcode'] ; ?>" />
</div>
<div><label for="Bedrooms">Bedrooms</label>
<input id="bedrooms" name="bedrooms" type="text" class="<?php echo $bedroomsError; ?>" value="<?php echo $formValue['bedrooms'] ; ?>" size="2" />
</div>
<div><label for="Price">Price</label><input id="price" name="price" type="text" size="8" class="<?php echo $priceError ; ?>" value="<?php echo $formValue['price'] ; ?>" />
</div>
<div>
<label for="branch">Area</label>
<select id="branch" name="branch" size="1" class="branch">
<?php if($formValue['branch']==''){
echo"<option selected='selected'>Yarm</option>
<option>Eaglescliffe</option>
<option>Stokesley</option>
<option>Ingleby Barwick</option>
<option>Middlesbrough</option>
<option>Other Villages</option></select> ";
}else{
$j=0;
$Town = Array('Yarm','Eaglescliffe','Stokesley','Ingleby Barwick','Middlesbrough','Other Villages');
echo "<option selected='selected'>".$formValue['branch']."</option>";
$j=0;
while($j<=5){
if($formValue['branch']==$Town[$j]){
$j=$j+1;
}else{
$name=$Town[$j];
echo "<option>".$name."</option>";
$j=$j+1;
}
}
echo"</select>";
}
?>
</div>
<div><label for="agentDescription">Agent Description</label>
<textarea id="agentDescription" name="agentDescription" class="<?php echo $agentDescriptionError ; ?>"><?php echo $formValue['agentDescription'] ; ?></textarea>
</div>
<div><label for="file">Property Image</label>
<input id="img" name="img" type="file" value="<?php echo $formValue['img'] ; ?>" /></div>
<div class="submit"><input name="Submit" type="Submit" class="btn" value="Add Property" /></div>
</fieldset>
</form>
</div>
<!--Info Text-->
<!--Contact Text-->
<!--Footer Info-->
</div>
</div>
</div>
<div id="footer">
<!--CSS Rollover Image Hack-->
<div class="cssRolloverImageHack_1"></div>
<div class="cssRolloverImageHack_2"></div>
<div class="cssRolloverImageHack_3"></div>
<div class="cssRolloverImageHack_4"></div>
<div class="cssRolloverImageHack_5"></div>
<div class="cssRolloverImageHack_6"></div>
<!--end footer-->
</div>
</body>
</html>
session_start();
include "../common.php";
include('class.upload.php');
//Check if the user has logged in
include "checkLoginSession.php";
//COLLECT POST data
$formValue=array();
foreach ($_POST as $key => $value) {
$formValue[$key] = strip_tags($value);
}
//SETUP SELECTION Dropdowns
//Updated 9.11.06
//To Fix issues with two option being display
//Branch
//if(isset($_POST['Submit'])){
//Check for empty fields and setup css error var
if($formValue['address2']==""){;
$message="Please fill in the field street";
$address2Error="address2Error";
}else{
if($formValue['address3']==""){
$message="Please fill in the field Town";
$address3Error="address3Error";}
else{
if($formValue['postcode']==""){
$message="Please fill in the field Postcode";
$postcodeError="postcodeError";}
else{
if($formValue['bedrooms']==""){
$message="Please fill in the field Bedrooms";
$bedroomsError="bedroomsError";}
else{
if($formValue['price']==""){
$message="Please fill in the field Price";
$priceError="priceError";}
else{
if($formValue['agentDescription']==""){
$message="Please fill in the field Agent Description";
$agentDescriptionError="agentDescriptionError";
}else{
DBConnect();
$Link = mysql_connect($Host, $User, $Password);
$agentID = $_SESSION['userID'];
//-------Routine for Dealing With Property Of Week-------//
//Sets the Flag to NO for all properties if the current property is SET to YES
$Query_propWeek= "SELECT id, propWeek FROM $table1 WHERE propWeek = 'Yes'";
$Result_propWeek = mysql_db_query ($DBName, $Query_propWeek, $Link);
$Row = array();
while($Row_propWeek = mysql_fetch_array($Result_propWeek)){
$Row[] = $Row_propWeek[id] ;
}
$Query_updatePropWeek = "UPDATE $table1 SET propWeek = 'No' WHERE id = ". implode(' or id = ', $Row);
if (mysql_db_query ($DBName, $Query_updatePropWeek, $Link)){
}
$propWeek = "Yes";
$imgpath = "propertyImages/tmp.jpg";
$imgpath2 = "propertyImages/tmp2.jpg";
$address1 = "notUsed";
$Query = "INSERT INTO $table1 VALUES ('0', '".mysql_escape_string($formValue['postcode'])."','".mysql_escape_string($formValue["price"])."', '".mysql_escape_string($formValue["branch"])."', '".mysql_escape_string($formValue["bedrooms"])."',
'".mysql_escape_string($address1)."', '".mysql_escape_string($formValue["address2"])."','".mysql_escape_string($formValue["address3"])."', '".mysql_escape_string($formValue["agentDescription"])."','".mysql_escape_string($propWeek)."',
'".mysql_escape_string($agentID)."', '".mysql_escape_string($imgpath)."', '".mysql_escape_string($imgpath2)."')";
echo $Query;
if (mysql_db_query ($DBName, $Query, $Link)){
//Need to copy the img file
//Bug fix on 27.07.07 we were not getting reliable number matches for the img fields
//This new routine is more complex but fixes the bug
//We now need to change to add image routine so that the image matches the id exactly
if(empty($formValue['img'])){
$img = "none";
$img2 = "none";
}else{
//Peform Select Query To Find THIS record only - It must match exactly
$Query = "SELECT id, propWeek FROM $table1 WHERE propWeek = 'Yes'";
$Result = mysql_db_query ($DBName, $Query, $Link);
$Row = mysql_fetch_array($Result);
$Propertyid = $Row[id];
//Generate the new img paths
$file1 = $Propertyid;
$file2 = $Propertyid;
$file1 = "propertyThumb".$file1 ;
$f = "propertyThumb".$file2 ;
$f = $f.=".jpg";
$fileLarge = "propertyLarge".$file2 ;
$fileLarge = $fileLarge.=".jpg";
$imgpath = "propertyImages/$f";
$imgpath2 = "propertyImages/$fileLarge";
//Peform UPDATE query to add in the new data for the img fields
$Query2 = "UPDATE $table1 SET img = '$imgpath', img2 = '$imgpath2' WHERE id = $Propertyid";
mysql_db_query ($DBName, $Query2, $Link)or die(mysql_error());
}
copy($_FILES['img']['tmp_name'], "../propertyImages/$fileLarge");
//Handle the image processing in the class
$handle = new upload($_FILES['img']);
if ($handle->uploaded) {
$handle->file_new_name_body = $file1;
$handle->file_new_name_ext = 'jpg';
$handle->image_resize = true;
$handle->image_x = 200;
$handle->image_y = 200;
$handle->image_ratio_y = true;
$handle->image_ratio_x = true;
$handle->jpeg_quality = 100;
/* $handle->image_text = '$title';
$handle->image_text_direction = 'h';
$handle->image_text_color = '#FF0000';
$handle->image_text_percent = 50;
$handle->image_text_font = 4;
$handle->image_text_y = 5;
$handle->image_text_x = 5; */
$handle->process('../propertyImages');
if ($handle->processed) {
echo 'image resized';
$handle->clean();
} else {
echo 'error : ' . $handle->error;
}
$Query3 = "SELECT MAX(id) FROM $table1";
$Result = mysql_db_query ($DBName, $Query3, $Link);
$Row = mysql_fetch_array($Result);
$new = $Row['MAX(id)'];
$message = "Property Created Successfully! <br /><a href='YourURL../displayPropFullDetails.php?propertySelect=$new target=_blank'><br />Click Here To Review New Property</a>";
}else{
$message = "Error Creating Property";
}
mysql_close($Link);
}
}
}
}
}
}
}
//}
?>
<!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" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>SMARTMOVE CMS Lettings and Management Ltd :: Administrator Page</title>
<!--Style Sheet-->
<?php echo $postcode ; ?>
<link href="../mainstyle.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" type="text/css" href="../AdminSmartmove.css" />
<link rel="stylesheet" type="text/css" href="../dataDisplay.css" />
<link rel="Shortcut Icon" href="favicon.ico"/>
<script src="Scripts/AC_RunActiveContent.js" type="text/javascript"></script>
<script src="Scripts/swfobject.js" type="text/javascript"></script></head>
<body>
<!--Main Content Area-->
<div id="content">
<div id="header">
<!--Main Navigation-->
<ul>
<li><span id="button1"><a href="../index.php" title="Click to view Home Page"></a></span></li>
<li><span id="button2"><a href="../about.php" title="Click to view About us Page"></a></span></li>
<li><span id="button3"><a href="../services.php" title="Click to view Services Page"></a></span></li>
<li><span id="button4"><a href="../properties.php" title="Click to view Properties Page"></a></span></li>
<li><span id="button5"><a href="../region.php" title="Click to view Region Page"></a></span></li>
<li><span id="button6"><a href="../contact.php" title="Click to view Contact Page"></a></span></li>
</ul>
<div id="adminLink">
<a href="admin/index.php"><img src="../images/transparent.gif" title="Click to go to Administrator Page" alt="Click to go to Administrator Page" width="10" height="10" border="0" /></a></div>
<div id="emailLink">
<a href="mailto:andrew@smartmove.com"><img src="../images/transparent.gif" title="Click to send email to webmaster@smartmove.com" alt="Click to send email to webmaster@smartmove.com" width="10" height="10" border="0" /></a></div>
<div id="sitemapLink">
<a href="sitemap.php"><img src="../images/transparent.gif" title="Click to view Site Map Page" alt="Click to view Site Map Page" width="10" height="10" border="0" /></a></div>
<!--Close header-->
</div>
<div id="container">
<div id="headerBox">
<div id="adminImage">
<img src="../images/admin_img.jpg" alt="Administrator Access" title="Administrator Access" width="412" height="54" /></div>
<!--Property Search-->
<div id="adminMenu">
<!--to show admin menu-->
<?php include("adminMenu.php"); ?>
<form method="post" action="" id="systemMessage">
<fieldset>
<legend>System Message</legend>
<?php echo $message;?>
</fieldset>
</form>
</div>
<div id="adminText">
<form action="<?php $_SERVER['PHPSELF']?>" method="post" enctype="multipart/form-data" name="form1" id="genericForm">
<fieldset>
<legend>Add New Property</legend>
<div><label for="Address2">Street</label><input id="address2" name="address2" type="text" class="<?php echo $address2Error ; ?>" value="<?php echo $formValue['address2']; ?>" /></div>
<div><label for="Address3">Town</label><input id="address3" name="address3" type="text" class="<?php echo $address3Error ; ?>" value="<?php echo $formValue['address3'] ; ?>" /></div>
<div><label for="Postcode">Postcode</label><input id="postcode" name="postcode" type="text" size="8" class="<?php echo $postcodeError ; ?>" value="<?php echo $formValue['postcode'] ; ?>" />
</div>
<div><label for="Bedrooms">Bedrooms</label>
<input id="bedrooms" name="bedrooms" type="text" class="<?php echo $bedroomsError; ?>" value="<?php echo $formValue['bedrooms'] ; ?>" size="2" />
</div>
<div><label for="Price">Price</label><input id="price" name="price" type="text" size="8" class="<?php echo $priceError ; ?>" value="<?php echo $formValue['price'] ; ?>" />
</div>
<div>
<label for="branch">Area</label>
<select id="branch" name="branch" size="1" class="branch">
<?php if($formValue['branch']==''){
echo"<option selected='selected'>Yarm</option>
<option>Eaglescliffe</option>
<option>Stokesley</option>
<option>Ingleby Barwick</option>
<option>Middlesbrough</option>
<option>Other Villages</option></select> ";
}else{
$j=0;
$Town = Array('Yarm','Eaglescliffe','Stokesley','Ingleby Barwick','Middlesbrough','Other Villages');
echo "<option selected='selected'>".$formValue['branch']."</option>";
$j=0;
while($j<=5){
if($formValue['branch']==$Town[$j]){
$j=$j+1;
}else{
$name=$Town[$j];
echo "<option>".$name."</option>";
$j=$j+1;
}
}
echo"</select>";
}
?>
</div>
<div><label for="agentDescription">Agent Description</label>
<textarea id="agentDescription" name="agentDescription" class="<?php echo $agentDescriptionError ; ?>"><?php echo $formValue['agentDescription'] ; ?></textarea>
</div>
<div><label for="file">Property Image</label>
<input id="img" name="img" type="file" value="<?php echo $formValue['img'] ; ?>" /></div>
<div class="submit"><input name="Submit" type="Submit" class="btn" value="Add Property" /></div>
</fieldset>
</form>
</div>
<!--Info Text-->
<!--Contact Text-->
<!--Footer Info-->
</div>
</div>
</div>
<div id="footer">
<!--CSS Rollover Image Hack-->
<div class="cssRolloverImageHack_1"></div>
<div class="cssRolloverImageHack_2"></div>
<div class="cssRolloverImageHack_3"></div>
<div class="cssRolloverImageHack_4"></div>
<div class="cssRolloverImageHack_5"></div>
<div class="cssRolloverImageHack_6"></div>
<!--end footer-->
</div>
</body>
</html>
G4uthier
Messages postés
131
Date d'inscription
dimanche 2 décembre 2007
Statut
Membre
Dernière intervention
23 juillet 2009
7
18 avril 2008 à 18:56
18 avril 2008 à 18:56
J'ai cett erreur la quand je veux uploader la photo . je comprends pas pourquoi je suis pas sous linux ,j'ai les droits...
INSERT INTO SM_properties VALUES ('0', 'TS4 3NN','899', 'Middlesbrough', '4', 'notUsed', 'laura street','Middlesbrough', 'Pretty','Yes', '1', 'propertyImages/tmp.jpg', 'propertyImages/tmp2.jpg')
Warning: copy(../propertyImages/) [function.copy]: failed to open stream: Permission denied in D:\wamp\www\Smart move\admin\addNewProperty2.php on line 115
INSERT INTO SM_properties VALUES ('0', 'TS4 3NN','899', 'Middlesbrough', '4', 'notUsed', 'laura street','Middlesbrough', 'Pretty','Yes', '1', 'propertyImages/tmp.jpg', 'propertyImages/tmp2.jpg')
Warning: copy(../propertyImages/) [function.copy]: failed to open stream: Permission denied in D:\wamp\www\Smart move\admin\addNewProperty2.php on line 115
R4f
Messages postés
441
Date d'inscription
dimanche 13 janvier 2008
Statut
Membre
Dernière intervention
5 mai 2008
62
18 avril 2008 à 19:12
18 avril 2008 à 19:12
Il faut faire attention car le serveur Web Apache tourne en tant qu'un certain utilisateur qui n'est pas le même que celui sous lequel tu fais tourner tes applications et sous lequel tu crées les répertoires...
Il faudrait remplacer copy par move_uploaded_file.
Il faudrait remplacer copy par move_uploaded_file.
G4uthier
Messages postés
131
Date d'inscription
dimanche 2 décembre 2007
Statut
Membre
Dernière intervention
23 juillet 2009
7
18 avril 2008 à 19:20
18 avril 2008 à 19:20
INSERT INTO SM_properties VALUES ('0', 'TS4 3NN','899', 'Middlesbrough', '4', 'notUsed', 'laura street','Middlesbrough', 'Pretty','Yes', '1', 'propertyImages/tmp.jpg', 'propertyImages/tmp2.jpg')
Warning: move_uploaded_file(../propertyImages/) [function.move-uploaded-file]: failed to open stream: Permission denied in D:\wamp\www\Smart move\admin\addNewProperty2.php on line 115
Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move 'd:/wamp/tmp\php8F.tmp' to '../propertyImages/' in D:\wamp\www\Smart move\admin\addNewProperty2.php on line 115
c'est toujours la meme chose . :(
Warning: move_uploaded_file(../propertyImages/) [function.move-uploaded-file]: failed to open stream: Permission denied in D:\wamp\www\Smart move\admin\addNewProperty2.php on line 115
Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move 'd:/wamp/tmp\php8F.tmp' to '../propertyImages/' in D:\wamp\www\Smart move\admin\addNewProperty2.php on line 115
c'est toujours la meme chose . :(
R4f
Messages postés
441
Date d'inscription
dimanche 13 janvier 2008
Statut
Membre
Dernière intervention
5 mai 2008
62
18 avril 2008 à 19:31
18 avril 2008 à 19:31
Existe-t-il bien un répertoire
D:\wamp\www\Smart move\propertyImages sur ta machine (il faut vérifier très scrupuleusement le chemin complet car c'est hyper-important que ça soit bien ça. Par exemple, pourrais-tu le lister les fichiers et répertoires de D:\wamp\www\Smart move\ ?
Je pense qu'on s'approche !
Raph
D:\wamp\www\Smart move\propertyImages sur ta machine (il faut vérifier très scrupuleusement le chemin complet car c'est hyper-important que ça soit bien ça. Par exemple, pourrais-tu le lister les fichiers et répertoires de D:\wamp\www\Smart move\ ?
Je pense qu'on s'approche !
Raph
G4uthier
Messages postés
131
Date d'inscription
dimanche 2 décembre 2007
Statut
Membre
Dernière intervention
23 juillet 2009
7
18 avril 2008 à 20:18
18 avril 2008 à 20:18
R4f
Messages postés
441
Date d'inscription
dimanche 13 janvier 2008
Statut
Membre
Dernière intervention
5 mai 2008
62
18 avril 2008 à 20:37
18 avril 2008 à 20:37
Tu pourrais remplacer copy($_FILES['img']['tmp_name'], "../propertyImages/$fileLarge"); par copy($_FILES['img']['tmp_name'], "../propertyImages/test.jpg");.
Naturellement, tous les fichiers seront renommés systématiquement en test.jpg mais c'ets juste pour un test...
Naturellement, tous les fichiers seront renommés systématiquement en test.jpg mais c'ets juste pour un test...
G4uthier
Messages postés
131
Date d'inscription
dimanche 2 décembre 2007
Statut
Membre
Dernière intervention
23 juillet 2009
7
18 avril 2008 à 20:41
18 avril 2008 à 20:41
plus d'erreur mais j'arrive sur une page blanche sur laquelle figure :
INSERT INTO SM_properties VALUES ('0', 'f','1', 'Yarm', '2', 'notUsed', 'h','f', 'ze','Yes', '1', 'propertyImages/tmp.jpg', 'propertyImages/tmp2.jpg')d:/wamp/tmp\php14.tmp
.
INSERT INTO SM_properties VALUES ('0', 'f','1', 'Yarm', '2', 'notUsed', 'h','f', 'ze','Yes', '1', 'propertyImages/tmp.jpg', 'propertyImages/tmp2.jpg')d:/wamp/tmp\php14.tmp
.
G4uthier
Messages postés
131
Date d'inscription
dimanche 2 décembre 2007
Statut
Membre
Dernière intervention
23 juillet 2009
7
18 avril 2008 à 20:47
18 avril 2008 à 20:47
pour le d:/wamp/tmp\php14.tmp
fais pas attention j'ai juste fait un echo du $files[img][temp]
fais pas attention j'ai juste fait un echo du $files[img][temp]