我试图从URL查询字符串中获取变量。但不知何故,它只有一个变量,而不是从查询字符串中获取所有变量。我真的不知道我的代码出了什么问题。下面是我想从无效形式打印出错误代码:从查询字符串获取变量
<?php
displayForm();
function displayForm(){
?>
<form action="./prod_add_action.php" method="post" name="addproductForm">
<fieldset>
<legend>Online Ordering System Setup</legend>
<label for="product_name">Product Name: </label><input type="text" name="product_name" value="" /><?php echo $_GET["name_error"]; ?>
<label for="product_date">Product Date: </label><input type="text" name="product_date" value="" /><?php echo $_GET["date_error"]; ?>
<label for="product_price">Product Price: </label><input type="text" name="product_price" value="" /><?php echo $_GET["price_error"]; ?>
<input name="add_button" type="submit" value="Add" />
<input name="reset_button" type="reset" value="Clear" />
</fieldset>
</form>
<?php
}
?>
,这里是我创建的查询字符串的代码:
$query_string = "name_error=" .urlencode($name_error) ."&date_error=" .urlencode($date_error) ."&price_error=" .urlencode($price_error);
header("Location: ./prod_add.php?$query_string");
exit();
在第一个代码,页面仅打印第一$ _GET ['name_error'],它应该包括$ _GET ['date_error']和$ _GET ['price_error。 '] 这是地址:
严,无需HTML逃生&S的URL,如果被用来做什么,他们都应该用于(分离数据)他们。 – petschekr
是的,我现在可以看到它,那是我的不好。非常感谢你,它是固定的:) – babygau