我试图从表中删除一行

时间:2014-04-30 00:25:04

标签: php mysqli admin edit sql-delete

AdminAccount.php

        <?php

        ob_start();
        include 'connection.php';
        $ses = $_SESSION['user_id'];

        $username = $_POST['username'];
        $password = $_POST['password'];
        $email = $_POST['email'];

        echo "<h3> User Account Information </h3>";

        if (isset($_SESSION["user_id"] )) {

            print "<table border=1 cellpadding='5' width = 100px height = 100px align='middle'>";

            print "<th>username</ th>";

            print "<th>Password</ th>";

            print "<th>email</ th>";

            print "<th>edit information</ th>";

            print "<th>delete information</ th>";

            $query = "SELECT * FROM Register";


            $result = mysqli_query($connection, $query);

            while ($row = mysqli_fetch_array($result)) {
                echo " <tr>";



echo "<td>" . $row['username'] . "</td>";

    echo "<td>" . $row['password'] . "</td>";

    echo "<td>" . $row['email'] . "</td>";

    echo "<td><a href='EditInfo.php?id=" . $row['user_id'] . "'>Edit</a></td>";

    echo "<td><a href='DeleteInfo.php?id=".$row["user_id"] ."' > delete </a> ";


                echo "</tr>";
        //echo "<td><a href='EditInfo.php?id=" . $row['user_id'] . "'>Edit</a></td>";

            }
            echo "</table>";
            }


            if(isset($_POST['submit'])){

                $query = ("UPDATE Register SET username = '$username' , password = '$password' , email = '$email' WHERE user_id='$ses'");


        $result = mysqli_query($connection,$query);


        header('location:ProtectedPage.php');   
        //Temporarily echo $query for debugging purposes    

        //run $query
        }               

EditInfo.php

        <form method="post" action="AdminAccount.php">
                <lable for ="Username" > Username: </lable> </br>
                <input type="text" name="username" value=''/> </br>

                <lable for ="Password" > Password: </lable> </br>
                <input type="password" name="password" /> </br>

                <lable for ="Email" > Email: </lable> </br>
                <input type="email" name="email" /> </br>

                <input type="submit" name="submit" value="submit" />
                <input type="reset"  value="clear" />
            </form>

DeleteInfo.php

        <?php
        session_start();
        include 'connection.php
        $ses = $_SESSION['user_id'];
        $query = "DELETE FROM Register WHERE user_id = " .$user_id;
        $result = mysqli_query($query);
        ?>

我的编辑链接有效,但是当我点击删除时,我将显示一个空白页面,命令将不会运行,任何帮助,因为这真的很烦我。

0 个答案:

没有答案