我收到此错误:
警告:无法修改标头信息-/home/rbd0uwxxuqqj/public_html/d2d/php/updateSchemeScript.php中已发送的标头(输出始于/home/rbd0uwxxuqqj/public_html/d2d/php/updateSchemeScript.php:140)在第165行。
此处第140行指的是:Weblink输入字段,而第165行指的是:header('location:updateScheme.php');
。如果我从代码中删除第140行,则它在页脚标记处显示错误,而以上代码中未显示该错误。但我会在这里添加它:
<footer class="navbar-fixed-bottom"> //After removing the line 140, now error shifts to this line
</footer>
下面是整个代码:
<?php
//**********validation************
$nameErr = $eligibilityErr = $documentsErr = $validityErr = $benefitErr = $benefit_formErr = "";
$name = $eligibility = $category = $documents = $validity = $benefit = $benefit_form = $weblink = "";
if ($_SERVER["REQUEST_METHOD"] !== "POST")
{
$_SESSION['srno'] = $_GET['srno'];
}
$srno = $_SESSION["srno"];
$sq="select * from scheme where srno='$srno'";
$sqr=mysqli_query($con, $sq) or die(mysqli_error($con));
$row=mysqli_fetch_array($sqr);
$flag=0;
if ($_SERVER["REQUEST_METHOD"] == "POST")
{
$flag=1;
if (empty($_POST["name"]))
{
$nameErr = "* Name is required";
$flag=0;
}
else
{
$name = $_POST["name"];
}
if (empty($_POST["eligibility"]))
{
$eligibilityErr = "* Eligibility is required";
$flag=0;
}
else
{
$eligibility = $_POST["eligibility"];
}
$category=$_POST["category"];
if (empty($_POST["documents"]))
{
$documentsErr = "* Documents is required";
$flag=0;
}
else
{
$documents = $_POST["documents"];
}
if (empty($_POST["validity"]))
{
$validityErr = "* Validity is required";
$flag=0;
}
else
{
$validity = $_POST["validity"];
}
if (empty($_POST["benefit"]))
{
$benefitErr = "* Benefit is required";
$flag=0;
}
else
{
$benefit = $_POST["benefit"];
}
if (empty($_POST["benefit_form"]))
{
$benefit_formErr = "* Form of Benefit is required";
$flag=0;
}
else
{
$benefit_form = $_POST["benefit_form"];
}
$weblink=$_POST["weblink"];
}
?>
<html>
<head>
<div class="container" >
<div class="row">
<div class="cont col-lg-4 col-lg-offset-4 col-md-4 col-md-offset-4 col-xs-12">
<div class="panel panel-primary">
<div class="panel-heading"><center>Update Inserted Schemes</center></div>
<div class="panel-body">
<form method="POST" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>">
<?php $sq="select * from scheme where srno='$srno'";?>
<div class="form-group">
<input type="text" class="form-control" name="name" id="name" value='<?php echo $row["name"]; ?>'>
<span class="error"><?php echo $nameErr;?></span>
</div>
<div class="form-group">
<input type="textarea" class="form-control" name="eligibility" id="eligibility" value='<?php echo $row["eligibility"]; ?>'>
<span class="error"><?php echo $eligibilityErr;?></span>
</div>
<div class ="form-group form-control">
<label >Select Category</label>
<select name="category" >
<option value='<?php echo $row["category"]; ?>' selected="selected"><?php echo $row['category']; ?></option>
<option value="farmer">Farmer</option>
<option value="seniorCitizen">Senior Citizen</option>
</select>
</div>
<div class="form-group">
<input type="textarea" class="form-control" name="documents" id="documents" value='<?php echo $row["documents"]; ?>'>
<span class="error"><?php echo $documentsErr;?></span>
</div>
<div class="form-group">
<input type="textarea" class="form-control" name="validity" id="validity" value='<?php echo $row["validity"]; ?>'>
<span class="error"><?php echo $validityErr;?></span>
</div>
<div class="form-group">
<input type="textarea" class="form-control" name="benefit" id="benefit" value='<?php echo $row["benefit"]; ?>'>
<span class="error"><?php echo $benefitErr;?></span>
</div>
<div class="form-group">
<input type="text" class="form-control" name="benefit_form" id="benefit_form" value='<?php echo $row["benefit_form"]; ?>'>
<span class="error"><?php echo $benefit_formErr;?></span>
</div>
<div class="form-group">
<input type="text" class="form-control" name="weblink" id="weblink" value='<?php echo $row["weblink"]; ?>'>
</div>
<center><button type="submit" class="btn btn-block btn-primary">Update</button></center>
</form>
</div>
</div><br/><br/>
</div>
</div>
</div>
</body>
</html>
<?php
$name=mysqli_real_escape_string($con, $name);
$eligibility=mysqli_real_escape_string($con, $eligibility);
$category=mysqli_real_escape_string($con, $category);
$documents=mysqli_real_escape_string($con, $documents);
$validity=mysqli_real_escape_string($con, $validity);
$benefit=mysqli_real_escape_string($con, $benefit);
$benefit_form=mysqli_real_escape_string($con, $benefit_form);
$weblink=mysqli_real_escape_string($con, $weblink);
if($flag)
{
$uq1="update scheme set name='$name', eligibility='$eligibility', category='$category', documents='$documents', validity='$validity', benefit='$benefit', benefit_form='$benefit_form', weblink='$weblink' where srno='$srno'";
$uqr1=mysqli_query($con, $uq1) or die(mysqli_error($con));
header('location:updateScheme.php');
}
?>