amplexus Posted July 20, 2012 Share Posted July 20, 2012 Hi, I'm creating a website, and want to have text on a portion of each page be editable by a non-tech, average user. I've created a form, and I've got it to work. I'm using .txt files. wht I've tried to do is create one page that has all of the pages' editable areas on it, each one displaying the current text, and a submit button to make the changes live. Problem: when you click any of the submit buttons, all of the areas update. here;s my code <!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=UTF-8" /> <title>Untitled Document</title> </head> <body> Edit copy for Homepage to appear as you want on the website, then click "update" <? if($_POST['Submit']){ $open = fopen("index.txt","w+"); $text = $_POST['update']; fwrite($open, $text); fclose($open); echo "<br /><br /><br />File updated to:<br /><br /><br />"; ?> <a href="../index.php">View Live Results</a><br /><br /><br /> <? $file = file("index.txt"); foreach($file as $text) { echo $text."<br />"; } }else{ $file = file("index.txt"); echo "<form action=\"".$PHP_SELF."\" method=\"post\">"; echo "<textarea Name=\"update\" cols=\"50\" rows=\"10\">"; foreach($file as $text) { echo $text; } echo "</textarea>"; echo "<input name=\"Submit\" type=\"submit\" value=\"Update\" />\n </form>"; } ?> Edit copy for About Us page to appear as you want on the website, then click "update" <? if($_POST['Submit']){ $open = fopen("about.txt","w+"); $text = $_POST['update']; fwrite($open, $text); fclose($open); echo "<br /><br /><br />File updated to:<br /><br /><br />"; ?> <a href="../about.php">View Live Results</a><br /><br /><br /> <? $file = file("about.txt"); foreach($file as $text) { echo $text."<br />"; } }else{ $file = file("about.txt"); echo "<form action=\"".$PHP_SELF."\" method=\"post\">"; echo "<textarea Name=\"update\" cols=\"50\" rows=\"10\">"; foreach($file as $text) { echo $text; } echo "</textarea>"; echo "<input name=\"Submit\" type=\"submit\" value=\"Update\" />\n </form>"; } ?> Edit copy for Rental Property Page to appear as you want on the website, then click "update" <? if($_POST['Submit']){ $open = fopen("rental.txt","w+"); $text = $_POST['update']; fwrite($open, $text); fclose($open); echo "<br /><br /><br />File updated to:<br /><br /><br />"; ?> <a href="../rental.php">View Live Results</a><br /><br /><br /> <? $file = file("rental.txt"); foreach($file as $text) { echo $text."<br />"; } }else{ $file = file("rental.txt"); echo "<form action=\"".$PHP_SELF."\" method=\"post\">"; echo "<textarea Name=\"update\" cols=\"50\" rows=\"10\">"; foreach($file as $text) { echo $text; } echo "</textarea>"; echo "<input name=\"Submit\" type=\"submit\" value=\"Update\" />\n </form>"; } ?> Edit copy for Crew to appear as you want on the website, then click "update" <? if($_POST['Submit']){ $open = fopen("crew.txt","w+"); $text = $_POST['update']; fwrite($open, $text); fclose($open); echo "<br /><br /><br />File updated to:<br /><br /><br />"; ?> <a href="../crew.php">View Live Results</a><br /><br /><br /> <? $file = file("crew.txt"); foreach($file as $text) { echo $text."<br />"; } }else{ $file = file("crew.txt"); echo "<form action=\"".$PHP_SELF."\" method=\"post\">"; echo "<textarea Name=\"update\" cols=\"50\" rows=\"10\">"; foreach($file as $text) { echo $text; } echo "</textarea>"; echo "<input name=\"Submit\" type=\"submit\" value=\"Update\" />\n </form>"; } ?> Edit copy for Order Lobsters to appear as you want on the website, then click "update" <? if($_POST['Submit']){ $open = fopen("order.txt","w+"); $text = $_POST['update']; fwrite($open, $text); fclose($open); echo "<br /><br /><br />File updated to:<br /><br /><br />"; ?> <a href="../order.php">View Live Results</a><br /><br /><br /> <? $file = file("order.txt"); foreach($file as $text) { echo $text."<br />"; } }else{ $file = file("order.txt"); echo "<form action=\"".$PHP_SELF."\" method=\"post\">"; echo "<textarea Name=\"update\" cols=\"50\" rows=\"10\">"; foreach($file as $text) { echo $text; } echo "</textarea>"; echo "<input name=\"Submit\" type=\"submit\" value=\"Update\" />\n </form>"; } ?> </body> </html> what's wrong? Quote Link to comment https://forums.phpfreaks.com/topic/265973-very-simple-cms-form-problem/ Share on other sites More sharing options...
Pikachu2000 Posted July 20, 2012 Share Posted July 20, 2012 If you want help, you should make it easy for those who might try to help you. People aren't likely to pore over a wall of unformatted code. Indent it properly, and post it within the forum's . . . BBCode tags and you'll probably get some responses. Quote Link to comment https://forums.phpfreaks.com/topic/265973-very-simple-cms-form-problem/#findComment-1362945 Share on other sites More sharing options...
amplexus Posted July 20, 2012 Author Share Posted July 20, 2012 I've replaced this thread with a new post that is modified. thx pikachu, I was too tired to remember to format correctly, my eyes were crossing, but I should have known better! Quote Link to comment https://forums.phpfreaks.com/topic/265973-very-simple-cms-form-problem/#findComment-1362978 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.