0
我的標題不起作用。標題不起作用
<?php
$name = mysql_prep($_POST['name']);
$pastor = mysql_prep($_POST['pastor']);
$head = mysql_prep($_POST['head']);
$schedule = mysql_prep($_POST['schedule']);
$venue = mysql_prep($_POST['venue']);
$id = mysql_prep($_GET['ministryid']);
$errors = array();
$required_field = array('name', 'pastor', 'address', 'schedule', 'venue');
foreach ($required_field as $fieldname) {
if(!isset($_POST[$fieldname]) || empty($_POST[$fieldname])) {
$errors[] = $fieldname;
echo "Sorry, you missed to complete {$fieldname} <br />";
}
else {
$query = "UPDATE ministry SET
name = '{$name}',
pastor = '{$pastor}',
head = '{$head}',
schedule = '{$schedule}',
venue = '{$venue}'
WHERE id = {$id}";
mysql_query($query);
if(mysql_affected_rows() == 1) {
header('location: editministry.php?');
exit;
} else {
echo "Updating Failed on {$s_ministry['name']} <b />".mysql_error();
exit;
}
}
}
require_once("include/footer.php");
每次成功更新時,鏈接都會更改其地址。
例如,當我更新id = 3
時,地址將更改爲editministry.php?ministryid = 3。
嘗試刪除從標題位置,標題(「Location:editministry.php」); – PravinS
仍然不能正常工作:( – user3278904
if if(mysql_affected_rows()== 1)condition is satisfied ?,嘗試echo mysql_affected_rows();並檢查你得到的值或者你可以檢查是否(mysql_affected_rows()> 0)條件 – PravinS