0

コード内の値 ID を edit.php に渡すのに問題があります。

displaynews では、データベースから記事を印刷します。また、edit.php にリダイレクトして $id 値を送信するリンクも作成します。

displaynews 機能へのリンク

http://snipt.org/zhla8

困っているところはここ

      <h3>EDIT NEWS ARTICLE</h3>
      <form id="EditNews" name="EditNews" method="POST" action="edit.php">
      <textarea name="editnewstext"><?php $news=Textarea(1);echo $news ?></textarea> <!--HERE i need to replace the 1 with id passing in displaynews -->
                        <input type="submit" name="Edit_News" id="Edit_News">

                        <?php
                       include 'db.php';
                       include'editnewsarticle.php';
                             if(isset($_POST['Edit_News']))
                          {

                                $content= $_POST['editnewstext'];
                  geteditnews(1,$content); //<!--HERE i need to replace the 1 with idpassing in displaynews -->
                                Header("location:Home.php");

                          }   

Edit.php ページへのリンク

http://snipt.org/zhkj8

GetnewsTextarea 関数へのリンク

http://snipt.org/zhlb9

editnewsarticle 関数へのリンク

http://snipt.org/zhki2

mysql 拡張機能がどのように減価償却されているか、および私のコードが sql インジェクションに対して開かれていることについてコメントしないでください。前もって感謝します

編集:ここに解決策があります

                       if(isset($_GET['id']))
                        {
                        $id = $_GET['id'];
                        $data = mysql_query("SELECT * FROM news WHERE id = '$id' "); 
                    }
                        ?>
4

2 に答える 2

1

edit.phpのこれらの変更は役に立ちますか?

if (isset($_POST['id']))
    $id = $_POST['id'];

<?php $news=Textarea($id);echo $news ?>  

geteditnews($id, $content); 
于 2013-03-20T12:36:44.720 に答える
1

フォームタグの直後にIDの非表示フィールドを追加します。そのような:

<form id="EditNews" name="EditNews" method="POST" action="edit.php">
    <input type="hidden" name="id" value="<?php echo $id; ?>">
于 2013-03-20T12:37:17.113 に答える