0

我的GET值在第一个if语句上很好,但是当它命中时update_submit我得到一个undefined variable错误。这仍然是测试脚本,所以没有验证

 <?php
session_start();
include "connect.php";

error_reporting(E_ALL);
ini_set('display_errors','1');

if(isset($_GET['pid']))
{
$get_item = $_GET['pid'];

echo "pid" . $get_item;//<--has value here

$get_products = $db->prepare("select * from `item` where 
                            `item_id` = '$get_item' LIMIT 1");

$get_products->execute();

    while ($row = $get_products->fetch())
    {
        $user_id =  $row['user_id'];
        $item_name = $row['item_name'];
        $item_description = $row['item_description'];
        $image = $row['photopath'];

    }

}

echo "pid" .$get_item;//<---has value here

if(isset($_POST['cancel_edit']))
{
header("Location: manage_items.php");
exit();
}
if(isset($_POST['update_submit']))//<<---lose it here
{
$get_products = $db->prepare("select `photopath` from `item` where 
                            `item_id` = '$get_item' LIMIT 1");
$get_products->execute();
$path= $get_products->fetchColumn(6);

形式

<form action="item_edit.php" method="post" enctype="multipart/form-data">

<input type = "text" name="item_name" value="<?php echo $item_name ?> "/>
<textarea name="item_description"><?php echo $item_description ?></textarea>

<p> <img src="<?php echo $image; ?>" width="75" height="75" /></p>
<input type="file" name="image_edit" value="<?php echo $image ?>"/>

<input name="img_edit" type="hidden" value="<?php echo $image ?>"/>
<input name="edit_form_id" type="hidden" value="<?php echo $get_item ?>">

<p><input type="submit" name="update_submit" value="Update"/></p>
<p><input type="submit" name="cancel_edit" value="Cancel"/></p>
</form>
4

1 回答 1

1

如果来自同一个表单,您是否正在为您的表单进行混合$_GET$_POST设置?使用时你有价值($_GET['pid']),但使用时没有($_POST['update_submit'])

于 2013-10-29T04:49:19.743 回答