Jump to content

very simple cms form problem


amplexus

Recommended Posts

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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.