【问题标题】:location: add ID to URL after update位置:更新后将ID添加到URL
【发布时间】:2015-08-03 09:36:11
【问题描述】:

下面更新一条数据库记录,完成后我想直接页面查看更新的记录。

header('location:view_resource.php?Resource_ID=$id');

我似乎无法将记录 id 添加到 url,它出现为:view_resource.php?Resource_ID=$id

完整代码如下:

 <?php
    include('conn.php');

    if(isset($_GET['Resource_ID']))
    {
        $id=$_GET['Resource_ID'];

        if(isset($_POST['submit']))
        {
            $name=$_POST['name'];
            $description=$_POST['description'];
            $query3=mysql_query("UPDATE z_resource SET Name='$name', Description='$description' WHERE Resource_ID='$id'");

            if($query3)
            {
                header('location:view_resource.php?Resource_ID=$id');
            }
        }

        $query1=mysql_query("select * from z_resource where Resource_ID='$id'");
        $query2=mysql_fetch_array($query1);
        ?>

        <form method="post" action="">
            Name:<input type="text" name="name" value="<?php echo $query2['Name']; ?>" /><br />
            Description:<input type="text" name="description" value="<?php echo $query2['Description']; ?>" /><br />

            <br />
            <input type="submit" name="submit" value="update" />
       </form>

       <?php
   }
?>

谢谢

【问题讨论】:

    标签: php mysql url


    【解决方案1】:

    把你的单引号''改成双引号""

    header('location:view_resource.php?Resource_ID=$id');
           ^^                                         ^^
    

    进入

    header("location:view_resource.php?Resource_ID=$id");
           ^^                                         ^^
    

    【讨论】:

      猜你喜欢
      • 2018-03-18
      • 1970-01-01
      • 2022-08-23
      • 1970-01-01
      • 2016-04-06
      • 2013-08-10
      • 2021-08-09
      • 2021-10-20
      • 1970-01-01
      相关资源
      最近更新 更多