douyan3478 2014-04-16 09:02
浏览 27

PHP cms在textarea中提交不起作用

i got a problem with my simple cms in php. I can get website content in an textarea and after i edited it i want to send the new edited content to the database, but thats not working. here is my form and functions

editContent.php

    <html>
    <head>
    <title> Basic CMS - Admin Area</title>
    <h1>Admin Area Edit Content</h1>
    </head>
    <body>
    <?php
    include ('includes/functions.php');

    $cont = getContent();

    session_start();
    if(isset($_SESSION['user'])) {
    ?>
    <span>Logged In! Welcome <?php echo $_SESSION['user']; ?></span>
    <a href="logout.php">Logout</a>
    <a href="editContent.php">Wijzig content</a>
    <a href="index.php">Admin Home</a>

    <form action="doEditcontent.php" method="post">
    <textarea name="contentarea"><?php echo $cont['content'];?></textarea><br>
    Submit : <input type="submit" value="submit" />
    </form>

<?php
} else {
    header("Location: login.php");
}
?>
</body>
</html> 

functions.php

<?php
include('includes/connect.php');

function getContent(){
    $query = mysql_query("SELECT content FROM taalcontent WHERE taalid = 1 AND contentid = 1") or die (mysql_error());
    return mysql_fetch_assoc($query);
    echo $query;
}

function editContent($pContent) {
    if(isset($pContent)){
        $query = "UPDATE taalcontent SET content content = '$pContent'  WHERE contendid = 1 AND taalid = 1";
    } else {
        echo "fout";
    }
    mysql_query($query);
}

doEditcontent.php

<?php
include('includes/functions.php');

if(isset($_POST['submit'])) {
    if(isset($_POST['contentarea'])){       
        editContent($_POST['contentarea']);
        header("Location: ../index.php?page=2");   
    } else 
        echo "Please enter some content!";
} else {
    header("Location: ../index.php?page=1");
}
?>
  • 写回答

2条回答 默认 最新

  • duanha3539 2014-04-16 09:05
    关注

    Try changing

    editContent($_GET['content']);
    

    to

     editContent($_POST['contentarea']);
    

    As it is you are asking it to set the content to whatever is in the ?get parameter (which I can't see referenced anywhere else so I'm guessing its not populated with anything).

    :)

    评论

报告相同问题?

悬赏问题

  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算