Page 1 of 1

Putting a Control Over Uploaded Picture

Posted: Mon Dec 10, 2007 8:50 pm
by haseebmaqsood
Hi,
Kindly,help m.I have make an edit form to change the profile. I would not like that after pressing edit button picture get off,because picture field is empty and every time i edit some thing i must have to tell the target location of the picture which i would not like to do.

The Code is here

***** PLEASE USE PHP/CODE TAGS *****

Code: Select all

<? 
include("connectivity.inc.php");

Function upLoadImage($sID,$status)
{
	if($_FILES['userfile']['type'] = "image/gif")
	{
	
	$uploaddir = 'images/';
	$uploadfile = $uploaddir . basename($_FILES['userfile']['name']);
	
		if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) {
			
			mysql_query("UPDATE images SET Status='$status',Path='$uploadfile' WHERE Star_ID='$sID'"); 														  																				}
		 else  {
			
			mysql_query("UPDATE images SET Status='$status',Path='' WHERE Star_ID='$sID'");
			   }
	}		   
}




if(isset($_POST['action']))
{  
 						
						$id=$_POST["id"];
						$First_Name=$_POST["firstname"];
						$Last_Name=$_POST["lastname"];
						$DOB=$_POST["dob"];
						$POB=$_POST["pob"];
						$FatherName=$_POST["fathername"];
						$MotherName=$_POST["mothername"];
						$Nationality=$_POST["nationality"];
						$Height=$_POST["height"];
						$Weight=$_POST["weight"];
						$Color=$_POST["color"];
						$Ethnicity=$_POST["ethnicity"];
						$Waiste=$_POST["waiste"];
						$Breast=$_POST["breast"];
						$Extra=$_POST["desc"];						
						$Status=$_POST["selectStatus"];
						
						
						upLoadImage($id,$Status);																
										
mysql_query("Update stars SET Star_ID='$id',First_Name='$First_Name',Last_Name='$Last_Name', DOB='$DOB',POB='$POB',Father_Name='$Father_Name', Mother_Name='$Mother_Name',National='$Nationality',Height='$Height', Weight='$Weight',Color='$Color',Ethnicity='$Ethnicity', Waiste='$Waiste',Extra='$Extra' where Star_ID='$id'");				 		
header("Location:controLPanel.php?value=viewActress&msg=edited");
}														

$result=mysql_query("Select s.First_Name,s.Last_Name,s.DOB,s.POB,s.Father_Name,s.Mother_Name,s.National, s.Height,s.Weight,s.Color,s.Ethnicity,s.Waiste,s.Breast,s.Extra,i.Status,i.Path FROM stars s INNER JOIN  images i ON s.Star_ID = i.Star_ID Where i.Star_ID=$_GET[id]");

while($row= mysql_fetch_array($result))
{

						$fname=$row["First_Name"];
						$lname=$row["Last_Name"];
						$dob=$row["DOB"];
						$pob=$row["POB"];
						$fan=$row["Father_Name"];
						$mon=$row["Mother_Name"];
						$na=$row["National"];
						$he=$row["Height"];
						$we=$row["Weight"];
						$co=$row["Color"];
						$eth=$row["Ethnicity"];
						$wa=$row["Waiste"];
						$br=$row["Breast"];
						$ex=$row["Extra"];
						$im=$row["Path"];						
						$st=$row["Status"];						

}
?>
<html>
<head>
<title>Edit Actress</title>
<link href="estyle.css" type="text/css" rel="stylesheet">
</head>

<body>
	
	<form name="frmEditActress" method="post" action="editActress.php" enctype="multipart/form-data">
			<table width="100%" border="0" align="center">
					
				<tr>
					 <td colspan="2" align="center"><span class="formHeading"> <strong>Edit  Actress</strong></span>				
					</br>
					<hr ></hr>	
					</br></br>	
					</td>
				</tr>
				
				
														
				<tr>
					 <td align="right" width="30%">
					<span class="formText"><strong>First Name:</strong></span>
					</td>
					
					<td align="left" width="70%">
					 	<input type="text" name="firstname" value="<?=$fname?>" size="45" />
					    <input type="hidden" name="id" value="<?=$_GET[id]?>"/>
					</td>
				</tr>							
					
				<tr>
					 <td align="right">
					  <span class="formText"><strong>Last Name:</strong></span>
					  </td>
					  <td align="left">
					  <input type="text" name="lastname" value="<?=$lname?>" size="45"/>
					  </td>		
				</tr>
				
				<tr>
						<td align="right">
						 <span class="formText"><strong>Extra:</strong></span>
						 </td>
						 <td align="left">
						<textarea cols="34" rows="5" name="desc"><? echo $ex; ?></textarea>	  
						 </td>
				</tr>
							
				<tr>
					 <td align="right">
					  <span class="formText"><strong>Date Of Birth:</strong></span>
					  </td>
					  <td align="left">
					  <input type="text" name="dob" value="<?=$dob?>"size="45"/>
					  </td>
				</tr>
							
				<tr>
					  <td align="right">
					 <span class="formText"><strong>Palce Of Birth:</strong></span>
					  </td>
					  <td align="left">
					  <input type="text" name="pob" value="<?=$pob?>" size="45"/>
					  </td>
				</tr>
			
				<tr>
						<td align="right">
						 <span class="formText"><strong>Father Name:</strong></span>
						 </td>
						 <td align="left">
						<input type="text" name="fathername" value="<?=$fan?>" size="45"/>	  
						 </td>
				</tr>
				
				<tr>
						<td align="right">
						 <span class="formText"><strong>Mother Name:</strong></span>
						 </td>
						 <td align="left">
						<input type="text" name="motherrname" value="<?=$mon?>" size="45"/>
  						 </td>
				</tr>
					
				<tr>
						<td align="right">
						 <span class="formText"><strong>Nationality:</strong></span>
						 </td>
						 <td align="left">
						<input type="text" name="nationality" value="<?=$na?>" size="45"/>	  
						 </td>
				</tr>
				
				<tr>
						<td align="right">
						 <span class="formText"><strong>Height:</strong></span>
						 </td>
						 <td align="left">
						<input type="text" name="height" value="<?=$he?>" size="45"/>	  
						 </td>
				</tr>
				
				<tr>
						<td align="right">
						 <span class="formText"><strong>Weight:</strong></span>
						 </td>
						 <td align="left">
						<input type="text" name="weight" value="<?=$we?>" size="45"/>	  
						 </td>
				</tr>
				
				<tr>
						<td align="right">
						 <strong>Colour:</strong>
						 </td>
						 <td align="left">
						<input type="text" name="color" value="<?=$co?>" size="45"/>	  
						 </td>
				</tr>
				
				<tr>
						<td align="right">
						 <span class="formText"><strong>Ethenicity:</strong></span>
						 </td>
						 <td align="left">
						<input type="text" name="ethenicity" value="<?=$eth?>" size="45"/>	  
						 </td>
				</tr>
				
				<tr>
						<td align="right">
						 <span class="formText"><strong>Breast:</strong></span>
						 </td>
						 <td align="left">
						<input type="text" name="breast" value="<?=$br?>" size="45"/>	  
						 </td>
				</tr>
				
				<tr>
						<td align="right">
						 <span class="formText"><strong>Waiste:</strong></span>
						 </td>
						 <td align="left">
						<input type="text" name="waiste" value="<?=$wa?>" size="45"/>	  
						 </td>
				</tr>
				
				<tr>
						<td align="right">
						 <span class="formText"><strong>Image:</strong></span>
						 </td>
						 <td align="left">
						<input type="file" name="userfile" value="<?=$im?>" size="45"/>
						</td>
				</tr>
				
				<tr>
						<td align="right">
							<span class="formText"><strong>Status Of Image:</strong></span>
						</td>
						<td align="left">
							<select size="1" name="selectStatus" >
							<? if ($st=="Main")	
							{
							echo "<option value='Main' 'selected'>Main</option>";
							echo "<option value='Extra'>Extra</option>";
							
							} 
							 else if ($st=="Extra")	
							{
							echo "<option value='Extra' 'selected'>Extra</option>";
							echo "<option value='Main'>Main</option>";																
							}
							?>
						    </select>
						</td>
				</tr>
				
				<tr> 
				
						 <td colspan="2" align="center">	
					   	<input type="submit" name="action" value="Edit" />
						 </td>
				</tr>
				<tr >
						<td colspan="2" align="center">
						</br>
						<hr></hr>
						<a href='picturesGallary.php?value=<?=$_GET[id]?>' class='textLink'>Pictures Gallary</a>
						</td>
				</tr>
			</table>
		</form>
</body>
</html>

Posted: Tue Dec 11, 2007 9:52 am
by feyd
What does placement of a "control" over a picture have to do with PHP?

Posted: Tue Dec 11, 2007 11:55 am
by haseebmaqsood
There is no link with control but i would like to ask that how can i protect from previously uploaded picture while editing the form

Posted: Tue Dec 11, 2007 1:11 pm
by feyd
Write out the code that defines what a previously uploaded picture is. Once you have that, it's a simple matter to integrate that into the checks the upload handler does.

Posted: Thu Dec 13, 2007 3:08 pm
by haseebmaqsood
Thanks Kindly Elaborate Little more. I would not like to change previous image if i do not give a new image in edit form,because image field is empty so image get blank

Posted: Thu Dec 13, 2007 4:58 pm
by nickvd
haseebmaqsood wrote:Thanks Kindly Elaborate Little more. I would not like to change previous image if i do not give a new image in edit form,because image field is empty so image get blank
Use logic in the script that processes the form. Check if the user submitted a new image, if they did then update the image, if they didn't then dont update the image.