永久性地在一个页面上发布一些表单数据

时间:2016-12-04 11:27:40

标签: php html forms

这个问题看起来很相似,但在任何地方都没有得到解答。我想要的是我设计一个带登录选项的网站。有一个名为" announcements.php"的特定页面。我希望网站访问者能够看到管理员发布的公告。所以,为了做到这一点,我创建了一个只有管理员可以访问并添加公告的页面(" newbroadcast.php")。该页面包含一个表单,管理员可以在其中撰写公告并提交。但是,访问announcements.php

的所有用户都应该可以访问该公告

代码(newbroadcast.php)

<div class="newbroad">
    <img src="content/images/broadcast.png" align="center" width="160px" height="160px">
    <form method="post" action="announcements.php">
        <strong>BROADCAST :&nbsp;&nbsp;</strong>
        <input type="text" name="broadd" placeholder="Write your new announcement here...">
        <input type="submit" name="submit">&#160;&#160;<input type="reset" name="reset">
    </form>
</div>

代码(announcements.php)

<div class="markcontent">
    <center><h1 class="whiteboard">CDC DEPARTMENT WHITEBOARD</h1></center>
    <hr>
    <?php
        $mynewbroad=$_POST["broadd"];
    ?>
    <marquee behavior="scroll" direction="down" scrollamount="2" onmouseover="this.stop();" onmouseout="this.start();">
        <center>
        <?php
            echo $mynewbroad;
        ?>
        </center>
    </marquee>

实际发生了什么?

一切正常,但是当管理员写一个新的公告或广播时,它会在页面上发布(&#34; announcements.php&#34;),我实际上想要发布它。然而,这不是永久性的。每当我打开页面本身时,它会显示错误=&gt;未定义的索引:broadd

他们是否可以永久显示管理员制作的广播?这个错误的可能解决方案是什么?

0 个答案:

没有答案