cass27 Posted June 16, 2009 Share Posted June 16, 2009 Hi I am trying to create a CMS system for my web page. I have managed to create a form that Updates the text. Now I would like the user to be able to use the form to upload an image to the page being edited (to be placed in the appropriate Div using the form? Is this possible? I know little about manipulating images. My images are in a seperate table for images (type size etc) but I have heard that using blobs is possibly not the best way to go. You can see the form for editing text at: http://www.louandelcats.co.uk/testingphp/astafftest/editform.php After clicking edit the updated page is listed at the top of the page. If you click on that it will take you to the page being updated. The edit form code is as follows: <?php include("../../connect/connection.php"); include("functions.php"); //in the tutorial this is changed to find selected subjects function (below down to header) /*--------------------------------------------script starts here-------------------------------- validation*/ if (isset($_POST['submit'])) { //if the page has been submitted submit is the submit button $errors = array(); // the array called errors will hold all the errors. $required_fields = array('page','title', 'content1','subtitle1', 'content2', 'subtitle2', 'content3', 'subtitle3', 'content4','permission' ); foreach($required_fields as $fieldname){ if (!isset($_POST[$fieldname]) || (empty($_POST[$fieldname]) && !is_numeric($_POST[$fieldname]))){ $errors[] = $fieldname; //the errors will be $fieldname. } } if (empty($errors)){ // catch form data------------------------------------------------------------------------------- $id = ($_GET['entry']); $page = mysqli_prep($_POST["page"]); $title = mysqli_prep($_POST["title"]); $content1 = mysqli_prep($_POST["content1"]); $subtitle1 = mysqli_prep($_POST["subtitle1"]); $content2 = mysqli_prep($_POST["content2"]); $subtitle2 = mysqli_prep($_POST["subtitle2"]); $content3 = mysqli_prep($_POST["content3"]); $subtitle3 = mysqli_prep($_POST["subtitle3"]); $content4 = mysqli_prep($_POST["content4"]); $permission = mysqli_prep($_POST["permission"]); //query $query = "UPDATE cms_careshowkit SET page='{$page}', title='{$title}', content1='{$content1}', subtitle1='{$subtitle1}', content2 = '{$content2}', subtitle2='{$subtitle2}', content3 = '{$content3}', subtitle3='{$subtitle3}', content4 = '{$content4}', permission='{$permission}' WHERE id = {$id}"; // execute query $result = mysqli_query($connection, $query); // test to see if the update worked if (mysqli_affected_rows($connection) == 1){ // success $message = "The subject was successfully updated"; $query2 = "SELECT id, title FROM cms_careshowkit"; $result = mysqli_query($connection, $query2) or die('Error, query failed'); if(mysqli_num_rows($result) == 0) { echo "Database is empty <br>"; } else { while(list($id, $title) = mysqli_fetch_array($result)) { ?> <a href="formStreet.php?id=<?php echo $id ;?>"><?php echo $title;?></a></br> <?php //return $result; } } }else{ //update failed $message = "The subject update failed"; $message .= "".mysqli_error($connection); } }else{ // errors occured $message = "There were " .count($errors). " errors in the form"; } } // end of issset post /*----------------------------------------------script ends here-----------------------------------*/ if(isset($_GET['entry'])){ $sel_name = $_GET['entry']; }else{ $sel_name = ""; } $allpages = get_subjects_by_id($sel_name); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Edit Form</title> <link href="/articles/content1.css" rel="stylesheet" type="text/css" /> </head> <body> <div class="wrapper"> <div class="articles"><?php navigationsa($sel_name); ?></div> <div class="form"><h2>Edit Article</h2> <?php if(!empty($message)){ echo "<p>".$message."</p>"; } ?> <form style="background:#FFFFFF; width:450px; padding:15px; border:thin ridge #666666" action="editForm.php?entry=<?php echo urlencode($allpages['id']);?>" method="post"> <p>Page:<input type="text" name="page" id="page" value="<?php echo $allpages['page'];?>"></p><br/> <p>Title:<input type="text" name="title" id="title" value="<?php echo $allpages['title'];?>"></p><br/> <p>Content1:<br/><textarea name="content1" cols="50" rows="10"><?php echo $allpages['content1'];?></textarea></p><br/> <p>subtitle1:<input type="text" name="subtitle1" id="subtitle1" value="<?php echo $allpages['subtitle1'];?>"></p><br/> <p>Content2:<br/><textarea name="content2" cols="50" rows="10"><?php echo $allpages['content2'];?></textarea></p><br/> <p>subtitle2:<input type="text" name="subtitle2" id="subtitle2" value="<?php echo $allpages['subtitle2'];?>"></p><br/> <p>Content3:<br/><textarea name="content3" cols="50" rows="10"><?php echo $allpages['content3'];?></textarea></p><br/> <p>subtitle3:<input type="text" name="subtitle3" id="subtitle3" value="<?php echo $allpages['subtitle3'];?>"></p><br/> <p>content4:<br/><textarea name="content4" cols="50" rows="10"><?php echo $allpages['content4'];?></textarea></p><br/> <p>permission:<input type="text" name="permission" id="permission" value="<?php echo $allpages['permission'];?>"></p><br/> <input type="submit" name="submit" value="Edit" /> </form> </div> </div> </body> </html> Any help with how to displaying images on the page I an updating text would be very useful Thanks, cass27 Link to comment https://forums.phpfreaks.com/topic/162461-enabling-users-to-display-image-and-text-using-form/ Share on other sites More sharing options...
cass27 Posted June 17, 2009 Author Share Posted June 17, 2009 would i need a seperate form? cass27 Link to comment https://forums.phpfreaks.com/topic/162461-enabling-users-to-display-image-and-text-using-form/#findComment-857766 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.