slaterino Posted October 7, 2008 Share Posted October 7, 2008 Hi I have created an image gallery and have created a cms page for adding images and also an edit page for modifying the image details. However, I seem to be having problems creating a section where the image can be updated. This is the code I have at the moment, but all it is producing is blank data and no errors. Can anyone see any problems with the code? I've got a feeling it must be to do with the position of a closed bracket but I've tried many different combinations and nothing seems to work. If someone could have a look that would be amazing! Thanks <?php include("../lib/config.php"); error_reporting(0); $id = $_GET['id']; if(isset($_POST['submit'])) { $member = $_POST['member']; $role = $_POST['role']; $sequence = $_POST['sequence']; if (isset ($_FILES['new_image'])) { $imagename = $_FILES['new_image']['name']; $source = $_FILES['new_image']['tmp_name']; $target = "../../images/committee_big/".$imagename; $member = $_POST['txtMember']; $role = $_POST['txtRole']; $sequence = $_POST['sequence']; move_uploaded_file($source, $target); $imagepath = $imagename; $save = "../../images/committee/" . $imagepath; //This is the new file you saving $file = "../../images/committee_big/" . $imagepath; //This is the original file list($width, $height) = getimagesize($file) ; $modwidth = 150; $diff = $width / $modwidth; $modheight = $height / $diff; $tn = imagecreatetruecolor($modwidth, $modheight) ; $image = imagecreatefromjpeg($file) ; imagecopyresampled($tn, $image, 0, 0, 0, 0, $modwidth, $modheight, $width, $height) ; imagejpeg($tn, $save, 100) ; $save = "../../images/committee/" . $imagepath; //This is the new file you saving $file = "../../images/committee_big/" . $imagepath; //This is the original file list($width, $height) = getimagesize($file) ; $modwidth = 80; $diff = $width / $modwidth; $modheight = $height / $diff; $tn = imagecreatetruecolor($modwidth, $modheight) ; $image = imagecreatefromjpeg($file) ; imagecopyresampled($tn, $image, 0, 0, 0, 0, $modwidth, $modheight, $width, $height) ; imagejpeg($tn, $save, 100) ; } if(!get_magic_quotes_gpc()) { $imagename = addslashes($imagename); $imagepath = addslashes($imagepath); } $result = mysql_query("UPDATE committee SET member='$member', role='$role', sequence='$sequence' WHERE id='$id' ",$connect); echo "<b>Thank you! Committee Member UPDATED Successfully!<br />You'll be redirected to Home Page after (4) Seconds"; echo "<meta http-equiv=Refresh content=4;url=index.php>"; } elseif($id) { $result = mysql_query("SELECT * FROM committee WHERE id='$id' ",$connect); while($myrow = mysql_fetch_assoc($result)) { $member = $myrow["member"]; $role = $myrow["role"]; $sequence = $myrow["sequence"]; ?> <h3>::Edit Committee Member</h3> <form method="post" action="<?php echo $PHP_SELF ?>"> <table> <input type="hidden" name="id" value="<? echo $myrow['id']?>"> <tr> <td>Member:</td><td><input name="member" size="40" maxlength="255" value="<? echo $member; ?>"></td></tr> <tr> <td>Role: </td><td><input name="role" size="40" maxlength="255" value="<? echo $role; ?>" /></td></tr> <tr> <td>Order: </td><td><input name="sequence" size="40" maxlength="255" value="<? echo $sequence; ?>"></td></tr> <tr> <td>Image:</td><td><?php echo "<img src='../../images/committee/".$myrow['path']."'>"; ?></td> </tr> <tr> <td>Add Image: </td><td><input name="new_image" id="new_image" size="30" type="file" class="fileUpload" /><br /></td></tr> <br /> </table><br /> <div align="center"><input type="submit" name="submit" value="Update Member"></div> </form> <? } } echo "<br /><a href=\"javascript:self.history.back();\"><-- Go Back</a>"; ?> Link to comment https://forums.phpfreaks.com/topic/127459-creating-an-update-image-page/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.