here my full code
index.php
Expand|Select|Wrap|Line Numbers
- //this link will post my data to next page
- <a href="updatepage.php?code=<?php echo $row['name']; ?>">update</a>
- updatepage.php
- //this page will get all data that want to update...
- <?php
- include("config.php");
- $name=$_GET['code'];
- $sql1 = "select * from imagename where name='$name'";
- $result = mysql_query($sql1) or die(mysql_error());
- $row=mysql_fetch_array($result);
- ?> <form name="form1" method="post" action="http://bytes.com/processupdatepage.php" class="formposition" enctype="multipart/form-data" > <table> <tr><td> <input type="hidden" name="id" value="<?php echo $row['id']; ?>" /></td></tr> <tr><td width="98">Image</td><td width="288">
- // here my prob...i can't get my image value but other data value work very well.....
- <input type="file" name="image" value="<?php echo $row['image'];?>" /></td></tr><br/> <tr><td>nane</td><td><input type="text" name="name" value="<?php echo $row['name']; ?>"/></td></tr><br/> <tr><td></td> <td colspan="2"> <input type="submit" name="submit" value="Save" /> </td></tr> </table> </form>
processupdatepage.php
Expand|Select|Wrap|Line Numbers
- <?php
- include("config.php");
- $id=$_POST['id'];
- $image=$_FILES['image']['name'];
- $name=$_POST['name'];
- $target = "http://bytes.com/images/";
- $target = $target . basename( $_FILES['image']['name']);
- $query = "UPDATE imagename SET name='$name', image='$image' WHERE id='$id'";
- $bb = mysql_query($query) or die(mysql_error());
- if($bb)
- {
- //Writes the photo to the server
- if(move_uploaded_file($_FILES['image']['tmp_name'], $target))
- {
- $sql001="UPDATE imagename SET image='$image' WHERE image='$image'";
- mysql_query($sql001);
- }
- else {
- }
- header("Location:index.php");
- }
- else
- {
- echo "Could not be updated";
- }
- ?>
sorry for my bad english...