PHP development news release system news modification submission page

Create the new_upd.php file

The functions that need to be completed in this chapter are as follows

3.jpg

The code is as follows

<?php
header("content-type:text/html;charset=utf8");
$title=$_POST['title'];
$content=$_POST['content'];
$id=$_GET['id'];
$time=date("y-m-d h:i:s");
$conn=mysqli_connect("localhost","root","root","News");
mysqli_set_charset($conn,"utf8");
if($conn){
    $sql="update new set title='$title',content='$content',cre_time='$time' where id='$id'";
    $que=mysqli_query($conn,$sql);
    if($que){
        echo "<script>alert('修改成功');location.href='new_list.php';</script>";
    }else{
        echo "<script>alert('修改失败,请检查后在提交');Location.href='new_list.php';</script>";
    }
}
?>

The above code can pass the new data from the modified page and then replace the old data


Note: Modify using update


This way our modification function can be completed. In the next chapter, we will implement the delete function


Continuing Learning
||
<?php header("content-type:text/html;charset=utf8"); $title=$_POST['title']; $content=$_POST['content']; $id=$_GET['id']; $time=date("y-m-d h:i:s"); $conn=mysqli_connect("localhost","root","root","News"); mysqli_set_charset($conn,"utf8"); if($conn){ $sql="update new set title='$title',content='$content',cre_time='$time' where id='$id'"; $que=mysqli_query($conn,$sql); if($que){ echo "<script>alert('修改成功');location.href='new_list.php';</script>"; }else{ echo "<script>alert('修改失败,请检查后在提交');Location.href='new_list.php';</script>"; } } ?>
submitReset Code