当我在管理面板中更新任何内容并单击更新按钮时,没有任何反应 - 即它既不会更新也不会转到我们单击编辑的页面。我正在使用免费托管。相同的代码正在本地主机上工作,但它不能用于免费托管。任何人都可以帮助我吗?
$sqlN="UPDATE selectplan SET plan_name='$planname',Plandetails='$Plandetails', Plantime='$Plantime', Plandate='$Plandate', plancost='$plancost', img='$image' WHERE id='$id__' ;";
$resultN=mysqli_query($conn,$sqlN);
这是完整的代码
<?php
require "conn.php";
session_start();
if(!isset($_SESSION['id']))
{
header('Location:index.php');
}
else
{
$id__=$_GET['id'];
$sql="SELECT * from selectplan where id='$id__' ;";
$result=mysqli_query($conn,$sql);
if((mysqli_num_rows($result))>0)
{
$row=mysqli_fetch_row($result);
$id_P=$row[0]; //id
$planname=$row[1];//name
$Plandetails=$row[2];
$Plantime=$row[3];
$Plandate=$row[4];
$plancost=$row[5];
$img__=$row[6];
}
}
if (isset($_POST['submit']))
{
$planname=$_POST["planname"];//name
$Plandetails=$_POST["Plandetails"];
$Plantime=$_POST["Plantime"];
$Plandate=$_POST["Plandate"];
$plancost=$_POST["plancost"];
if($planname==""||$Plandetails==""||$Plantime==""||$Plandate==""||$plancost=="")
{
echo "Please fill in all the fields";
}
else
{
$target="images/".basename($_FILES['image']['name'] );
//get all the submitted data from the form
$image=$_FILES['image']['name'];
//now move upload image to folder
if (move_uploaded_file($_FILES['image']['tmp_name'], $target))
{
echo "image upload";
}
$sqlN="UPDATE selectplan SET plan_name='$planname',Plandetails='$Plandetails', Plantime='$Plantime', Plandate='$Plandate', plancost='$plancost', img='$image' WHERE id='$id__' ;";
$resultN=mysqli_query($conn,$sqlN);
if ($resultN) {
header('Location:profile.php');
}
}
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Edit Plan</title>
</head>
<body class="t">
<p><a href="userlist.php">Back to Profile</a>
||
<a href="logout.php">Logout Now</a></p>
<br> <br><br>
<form action="profile.php" method="POST" enctype="multipart/form-data" >
Plan Name:<br><textarea name="planname" id="" value="" cols="80" ><?php echo $planname; ?></textarea><br>
Plan Details:<br><textarea name="Plandetails" id="" value="" cols="80" rows="6"><?php echo $Plandetails; ?></textarea><br>
Plan Time:<br><input type="time" name="Plantime" id="" value="<?php echo $Plantime; ?>" /><br>
Plan Date:<br><input type="date" name="Plandate" id="" value="<?php echo $Plandate; ?>" /><br><br>
Plan Cost:<br><input type="numbers" name="plancost" id="" value="<?php echo $plancost; ?>" /><br><br>
Image:<br><?php echo "<img src='images/$img__'"; ?> alt="Tourism" height="150" width="300" > <br><input type="hidden" name="size" value="1000000"><input type="file" name="image" /><br></br> <input type="submit" name="submit" value="Update now ">
</form>
</body>
</html>
答案 0 :(得分:0)
我认为您的问题出在conn.php中 您的身份验证值不正确 在conn.php中,yku应该更改当前localhost的值并更改用户并传递