View Single Post
  #4 (permalink)  
Old Apr 15th, 2008, 21:15
markusdavid markusdavid is offline
Junior Member
Join Date: Aug 2007
Location: London
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Re: upload images through updating a form

Hiya and thanks for the replies.
The open and closed form tags are from copying and pasting the code here, as this is just a snippet of the complete code.

I tried to use this code in the update.php file, but it didn’t work.

PHP: Select all

//This is the directory where images will be saved 
  
$target "http://www.webforumz.com/images/"
  
$target $target basename$_FILES['photo']['name']);
   
  
QUERY (from the update.php code below)
   
  
//Writes the photo to the server 
  
if(move_uploaded_file($_FILES['photo']['tmp_name'], $target)) 
  { 
   
  
//Tells you if its all ok 
  
echo "The file "basename$_FILES['uploadedfile']['name']). " has been uploaded, and your information has been added to the directory <br><a href=\"view.php\">click here</a> to update another record<br>"
  } 
  else { 
   
  
//Gives and error if its not 
  
echo "Sorry, there was a problem uploading your file <br><a href=\"addpropertyform.php\">click here</a> to add another Property<br>"
  } 

Below is the update.php code

PHP: Select all

<?php
   
  
foreach($HTTP_POST_VARS as $varname => $value)
  
$formVars[$varname]=$value;
   
  
mysql_connect("host""table""password"); 
  
mysql_select_db("database"); 
   
  echo 
"Record updated<br><a href=\"view.php\">click here</a> to update another record<br>";
   
  
$query="UPDATE property SET ".
  
"name= \"".$formVars["name"]."\",".
  
"photo= \"".$formVars["photo"]."\",".
  
"desc6= \"".$formVars["desc6"].
  
"\" WHERE id = \"".$formVars["id"]."\"";
  
mysql_query($query);
   
  
?>
Thanks for all the answers and help!!!

Last edited by saltedm8; Apr 17th, 2008 at 17:30. Reason: added [php] tags
Reply With Quote