eddie07 Posted March 10, 2007 Share Posted March 10, 2007 Hi, I'm hoping somebody out there can help. I have a website which has a monthly specials section, I'd like this section to be administered by a simple form that allows for the current special to be edited e.g. name, date, text about special and a simple image upload that will resize to a pre-defined size. This is all I would like the script to do, I wouldn't want to be able to add extra content, multiple users, create pages, change design, allow for formatting etc. just update the one section of the site, I'd assume this section is being retrieved from a mysql database which I can access on the server and using php to communicate with the database. So basically I require a form to update the database row that would populate this section of the "Monthly Specials" page using php and mysql. I have looked through the available scripts but haven't been able to find anything without the bells and whistles, as I'm a designer and not a programmer I would find it difficult to customise an existing script and would like to keep this as simple as possible to begin with. I'm hoping somebody can point me in the right direction, any help would be greatly appreciated. Cheers. Link to comment https://forums.phpfreaks.com/topic/42165-simple-form-based-cms/ Share on other sites More sharing options...
johnnytickets Posted March 11, 2007 Share Posted March 11, 2007 Hi Eddie.. I'm also more of a designer, and am doing something similar to what you are doing. I am not updating a database though.. just a flat text file, and a web page. You may be able to sift through this simple stuff and port it out to what you need. There are 4 pages involved: the editing page, the processing page, a text file (i use this instead of a database), and an html page that you might want to use as an include for the final output I've never posted here so I don't know if I can just paste these snippets in here but here goes: This is what would go on the editing page: edit.php or whatever // First the image part: <form name="uploadimage" method="post" action="" enctype="multipart/form-data"> <input type="File" name="imagefile" size="30" maxlength="120"> <input type="submit" name="Submit" value="Upload"> </form> <? if(isset( $Submit )) { if ($_FILES['imagefile']){ @copy ($_FILES['imagefile']['tmp_name'], "../images/".$_FILES['imagefile']['name']); // @ hides warnings echo "<img src=\"http://absoluteURLto/images/" . $_FILES['imagefile']['name'] . "\"border=\"0\" alt=\"\"><BR>"; PRINT "\n\n".$_FILES['imagefile']['name'].""; } } ?> //This is the text part followed by image info to be passed <form name="form" method="POST" action="theprocessingpage.php" onSubmit="return"> <textarea name="main_text" cols="60" rows="8" wrap="physical"> <? include("flatfile.txt") ?> </textarea> <? $new_image = "" . $_FILES['imagefile']['name'] . ""; echo "<input type=\"hidden\" name=\"new_image\" value=\"$new_image\">"; ?> <input type="submit" name="Submit" value="Submit"> </form> That's the basic texarea. The reason "flatfile.txt" is included in the textarea is so that the next time the page is edited, the current text will be there. You can just eliminate that if you don't see any need for it.. it is handy if the person editing doesn't need to change the whole textarea. Also, make sure your paths are correct. Here's the processing page: "theprocessingpage.php" or whatever. // This part passes the text to the flatfile and overwrites what was there previously <? $file = "flatfile.txt"; $contents = "$file"; $fp = fopen ($file,"w+"); $main_text = stripslashes($main_text); fwrite ($fp,$main_text); fclose ($fp); ?> /* This part passes the new data to the page and saves to another file (used as the include for final output */ <?php ob_start(); ?> <? // begin main text $main_text = stripslashes ($main_text); echo str_replace("\r",'<br>',$main_text); // end main text if ("$new_image" == "") { echo ""; } else { echo "<img id=\"01\" src=\"http://absoluteURLwhatever.com/images/" . $new_image . "\" border=\"0\"><br>"; } ?> <?php $file = "finaloutput.html"; $fp = @fopen($file, 'w'); @fwrite($fp, ob_get_contents()); @fclose($fp); ob_end_flush(); ?> that's it. You can set your image dimensions within the code that you see above. Hope this helps.. I am new to this and figured it out on my own... you need to make sure your permissions are ok, and your file names, etc... I think it will even create the pages if they don't already exist. Good luck! JT . Link to comment https://forums.phpfreaks.com/topic/42165-simple-form-based-cms/#findComment-204999 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.