附加文件而不是重新创建它 - PHP / HTML

时间:2016-03-18 15:10:24

标签: php html

我尝试过几件事,但我似乎无法更新此内容而不是重新创建文件。

在这里得到了很多用户的帮助,我在我的工厂为我们的厨师创建了一个菜单模板。他输入了他的信息并自动创建了一个菜单,其中包含各种奇特的图像。

我现在希望的是,如果他需要更改菜单项,他不必重新输入每天的信息。我已经在FILE_APPEND上阅读了如fopen但似乎并没有做我需要的事情。

这是我正在使用的剧本。

<?php
$MessageMondayMain = $_POST['MessageMondayMain'];
$MessageTuesdayMain = $_POST['MessageTuesdayMain'];
$MessageWednesdayMain = $_POST['MessageWednesdayMain'];
$MessageThursdayMain = $_POST['MessageThursdayMain'];
$MessageFridayMain = $_POST['MessageFridayMain'];
$MessageMonday = $_POST['MessageMonday'];
$MessageTuesday = $_POST['MessageTuesday'];
$MessageWednesday= $_POST['MessageWednesday'];
$MessageThursday = $_POST['MessageThursday'];
$MessageFriday = $_POST['MessageFriday'];
$MessageDate = $_POST['MessageDate'];

ob_start();
?>

<META http-equiv='Content-Type' content='text/html; charset=UTF-8'>
<html>
<head>
<title>GCH Cafe Menu</title>

<style>
.menu {
  padding-top: 22px;
  padding-right: 350px;
  box-sizing: border-box;
  margin: 0 auto;
  line-height: 100%;
  color: black; 
  overflow-y: scroll;

}


.menu h1 {
  padding-top: 1px;
  font-size: 40px;
  font-family: candara;
  position: relative;

}

.menu h2 {
  z-index:3
  font-size: 30px;
  font-family: Time New Roman;
  text-decoration: Underline;
  color: black;
  text-transform: uppercase;
  color: rgb(54,113,91);
}

.menu h3 {
  z-index:3
  font-size:25px;
  font-family: candara;
  text-transform: uppercase;
  text-weight: bold;
  color: rgb(152,180,155);

}

.menu h4 {
  z-index:3
  font-family: candara;
  font-size: 18px;
  line-height:100%;
  width: 650px;
  color: gray;
}

.container { 
position:absolute; 
}

.outline {
position: absolute; 
left: -570px; 
z-index:1
} 

.chef {
position: absolute; 
top: 90px; 
left: 150px; 
z-index:2
}

.date {
position: absolute;
top: 810px;
right: 210px;
z-index:2
}


</style>
</head>

<body bgcolor="#f2f2f2">
<center>




<div class="container">
<img class="outline" src="plain.png" height="825" width="750">
<img class="chef" src="chef.png" height="690" width="450">
</div>

    <div class="menu">
        <h1><img src="cafe2.png" height="100" width="225"></h1>
        <br>
        <h2>Monday</h2>
        <h3>-<?php echo nl2br ($MessageMondayMain);?>-</h3>
        <h4><?php echo nl2br($MessageMonday); ?></h4>

        <h2>Tuesday</h2>
        <h3>-<?php echo nl2br ($MessageTuesdayMain);?>-</h3>
        <h4><?php echo nl2br($MessageTuesday); ?></h4>

        <h2>Wednesday</h2>
        <h3>-<?php echo nl2br ($MessageWednesdayMain);?>-</h3>
        <h4><?php echo nl2br($MessageWednesday); ?></h4>

        <h2>Thursday</h2>
        <h3>-<?php echo nl2br ($MessageThursdayMain);?>-</h3>
        <h4><?php echo nl2br($MessageThursday); ?></h4>

        <h2>Friday</h2>
        <h3>-<?php echo nl2br ($MessageFridayMain);?>-</h3>
        <h4><?php echo nl2br($MessageFriday); ?></h4>



    <div class="date">
        <h2>Menu Date:<br><br><?php echo ($MessageDate);?></h2>
    </div>

    </div>
</div>
</center>
</body>
</html>

<?php
$html = ob_get_contents();
ob_end_clean();

$filename = "menu.html";

 file_put_contents($filename, $html);

echo file_get_contents("menu.html");
?>

0 个答案:

没有答案