无法更新phpmyadmin DB

时间:2017-11-19 18:41:29

标签: php sql-update

数据库值未更新

在此处使用网络表单。我想更新数据库中的用户信息。使用AJAX从列表中提取并生成信息。单击“更新信息”时,数据库应更新给定值。我现在只是在“FirstName”上测试它。代码运行,我没有错误,但我的数据库没有更新。

Process.php:

    <body>
    <?php
        if (!isset($_SESSION['email']))
                 Header ("Location:logout.php") ;



        if(isset($_POST['submit'])){
            $NewFirstName = trim($_POST['NewFirstName']);
            $StudentPID = $_POST['ca'];
            $sql = "update Student SET FirstName=".$NewFirstName."where StudentPID = ".$StudentPID."";
            $PleaseUpdate = mysql_query($sql);

            //echo "<script type='text/javascript'>alert('Data was successfully inserted')</script>";
        }
    ?>
    <form name="input" action="process.php" method="post">
        Ajax Demo

        <br/><br/>
        Select a Student: <br/><br/>
        <select name="ca" onchange="showDetail(this.value)">
        <?php print GetCategory(); ?>
        </select>

              <div id="txtHint"><b>Person info will be listed here.</b></div>
        <?php ?>
        <br />
 <input type="submit" name = "submit" value="Update Information"> 


    </form>


        <br/><br/>

        <a href="logout.php">Logout</a>

    </body>
</html>

GetDetail.php:

<?php session_start(); //this must be the very first line on the php page, to register this page to use session variables
    //if this is a page that requires login always perform this session verification
    require_once "inc/sessionVerify.php";
    require_once "dbconnect.php";

    if (!isset($_SESSION['email']))
        Header ("Location:logout.php") ;

    $q = $_GET['q']; //get the values passed from this query string
    $sql = "select * from Student where StudentPID = '".$q."'";         

            $result = $DB->GetAll($sql);                        
                     //display the result in a table
            print '<br /><br /><span style="color:red">Data retrieved from database:</span><br/ >';

            //get the rows
            $i = 0; //This is used to remember how many checkboxed created in total
            foreach ($result as $row)
            {
                //Now make the form
                print( '<form action="getDetail.php" method="post">
                First Name: <input type="text" id="NewFirstName" name="NewFirstName" value='.$row["FirstName"].'><br>
                Last Name: <input type="text" id="" name="" value='.$row["LastName"].'><br>         
                </form>
                ');
            }
            print '</table>';   
?>

0 个答案:

没有答案