I am not view my image and not updating my newblob image.
Anyone can help me make this work???
Thanks.
This is celebrities.php
Code: Select all
<?php
extract($_POST);
if(isset($submit)==true)
{
mysql_connect("localhost","root","") or die(mysql_error());
mysql_select_db("lyrics") or die(mysql_error());
$file= $_FILES['file']['tmp_name'];
if (!isset ($file))
echo "Please select an Image.";
else
{
$image= addslashes(file_get_contents($_FILES['file']['tmp_name']));
$image_name= addslashes($_FILES['file']['name']);
$image_size= getimagesize($_FILES['file']['tmp_name']);
if ($image_size== FALSE)
echo "That's not an image.";
}
$query="insert into celebrities values ('', '$artist', '$info','$image_name','$image')";
mysql_query($query);
header("refresh:0;url= 'celebrities.php'");
exit();
}
?>
<form name="celebrities" enctype="multipart/form-data" action="celebrities.php" method="post">
<table width="700" border="0" cellspacing="0" cellpadding="0">
<tr>
<td colspan="2">Manage Celebrities</td>
</tr>
<tr>
<td height="20" colspan="2"> </td>
</tr>
<tr>
<td width="100" height="25">Singer</td>
<td width="600" height="25" align="left"><input type="text" name="artist" size="20"></td>
</tr>
<tr>
<td width="100" height="25">Info</td>
<td width="600" height="25" align="left"><textarea name="info" cols="30" rows="5"></textarea> </td>
</tr><br/>
<tr>
<td width="100" height="25">Product Image</td>
<td>
<input type="file" name="file" />
</td>
</tr>
<tr>
<tr>
<td width="100" height="25"> </td>
<td width="600" height="25" align="left"><br/>
<input type="submit" name="submit" value="upload"></td>
</tr>
<tr>
<td height="30"> </td>
</tr>
<table width="800" border="0" cellspacing="1" cellpadding="0">
<tr>
<td width="150" bgcolor="#BFE6FF" align="center" >Celebrities-ID</td>
<td width="100" bgcolor="#BFE6FF" align="center" >Singer</td>
<td width="150" bgcolor="#BFE6FF" align="center" >About</td>
<td width="100" bgcolor="#BFE6FF" align="center" >Name</td>
<td width="100" bgcolor="#BFE6FF" align="center" >Image</td>
<td width="100" bgcolor="#BFE6FF" align="center" colspan="2" ></td>
</tr>
<?php
mysql_connect("localhost","root","");
mysql_select_db("lyrics");
$id=mysql_insert_id();
$file= $_FILES['file']['tmp_name'];
$image_name= addslashes($_FILES['file']['name']);
$sql = mysql_query("SELECT * FROM celebrities ORDER BY artist");
while ($row = mysql_fetch_array($sql))
{
$id = $row["id"];
$artist = $row["artist"];
$info = $row["info"];
$image_name = $row["image_name"];
$image = $row["image"];
echo "<tr>
<td bgcolor=\"#F2FAFF\" align=\"center\">$id</td>
<td bgcolor=\"#F2FAFF\" align=\"center\">$artist</td>
<td bgcolor=\"#F2FAFF\" align=\"center\">$info</td>
<td bgcolor=\"#F2FAFF\" align=\"center\">$image_name</td>
<td bgcolor=\"#F2FAFF\" align=\"center\"> <img src=celebrities.php?id=$id >; </td>
<td bgcolor=\"#F2FAFF\" align=\"center\" class=\"lyrics\"><a href='editcelebrities.php?pid=$id'>Edit</a> </td><br/>
<td bgcolor=\"#F2FAFF\" align=\"center\" class=\"lyrics\"><a href='deletecelebrities.php?deleteid=$id'> Delete</a></td>
</tr>";
}
?>
</table>
</td>
</tr>
</table>
</form>
____________________________________________
This is editcelebrities.php
<?php
$targetID=$_GET['pid'];
if(isset($_POST["button"]))
{
$artist=$_POST['artist'];
$info=$_POST['info'];
$file= $_POST[$_FILES['file']['tmp_name']];
$image_name= $_POST[($_FILES['file']['name'])];
$image= $_POST[$_FILES['file']['tmp_name']];
$image_size= $_POST[($_FILES['file']['tmp_name'])];
mysql_connect("localhost","root","")or die(mysql_error());
mysql_select_db("lyrics")or die(mysql_error());
$query= mysql_query("UPDATE celebrities SET image='$image',info='$info',image_name='$image_name', artist='$artist' WHERE id='$targetID'") or die(mysql_error());
header("location: celebrities.php");
exit();
}
?>
<?php
mysql_connect("localhost","root","");
mysql_select_db("lyrics");
if(isset($_GET['pid'])){
$targetID=$_GET['pid'];
$query=mysql_query("SELECT * FROM celebrities WHERE id='$targetID' LIMIT 1");
$pCount=mysql_num_rows($query);
if($pCount>0){
while($row= mysql_fetch_array($query)){
$id = $row['id'];
$artist = $row['artist'];
$info = $row['info'];
$image_name = $row['image_name'];
$location=$row['image'];
}
}else{
echo "Sorry ";
}
}
?>
<form name="form1" method="post">
<table width="700" border="0" cellspacing="0" cellpadding="0">
<tr>
<td colspan="2">Edit Celebrity</td>
</tr>
<tr>
<td height="20" colspan="2"> </td>
</tr>
<tr>
<td width="100" height="25">Singer</td>
<td width="600" height="25" align="left"><input type="text" name="artist" size="20" value="<?php echo "$artist"; ?>"></td>
</tr>
<tr>
<td width="100" height="25">Info</td>
<td width="600" height="25" align="left"><textarea name="info" cols="30" rows="5"><?php echo "$info"; ?></textarea></td>
</tr>
<tr>
<td width="100" height="25">Image_Name</td>
<td width="600" height="25" align="left"><input type="text" name="name" size="20" value="<?php echo "$image_name"; ?>"></td>
</tr>
<tr>
<td width="100" height="25">Image</td>
<td width="600" height="25" align="left"> <input type="file" name="file" /></td>
</tr>
<tr>
<td width="100" height="25"> </td>
<td width="600" height="25" align="left">
<input name="thisID" type="hidden" value="<?php echo $pid; ?>" />
<input type="submit" name="button" id="button" value="upload" /></td>
</tr>
</table>
</form>