PHP 挣扎。错误 404

PHP struggles. Error 404

正在尝试创建一个 crud function/contact 列表。用户登录后被带到此页面:

通过单击编辑功能,我希望将用户带到一个允许他们编辑联系方式的页面。目前正在努力使 link 正常运行。

link 照片是我的 /view 文件。看起来像这样:

<?php 

session_start();

if(isset($_SESSION['u_uid'])){

$uid = $_SESSION['u_id'];

require_once('connect.php');
$ReadSql = "SELECT * FROM `contact` WHERE users_id=$uid ORDER BY Name";
$res = mysqli_query($connection, $ReadSql);

?>

<head>
<title>Motoko</title>
    <!-- Latest compiled and minified CSS -->
<link rel="stylesheet" 
href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">

 <!-- Latest compiled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js">
</script>
</head>
<body> 
<div class="container">
    <div class="row">
    <table class="table">
        <tr>

            <th><strong>Name</strong></th>
            <th><strong>Company</strong></th>
            <th><strong>Title</strong></th>
            <th><strong>Phone</strong></th>
            <th><strong>Email</strong></th>
            <th><strong>Address</strong></th>
            <th><strong>Extras</strong></th>
        </tr>
        <?php 
        while($r = mysqli_fetch_assoc($res)){
        ?>
        <tr> 
            <td><?php echo $r['Name']; ?></td> 
            <td><?php echo $r['Company']; ?></td> 
            <td><?php echo $r['Title']; ?></td> 
            <td><?php echo $r['Phone']; ?></td> 
            <td><?php echo $r['Email']; ?></td> 
            <td><?php echo $r['Address']; ?></td> 
            <td><a href="crud/update.php?id=<?php echo $r['id'] ?>">Edit</a></td>
            <td><input type="button" onClick="deleteme(<?php echo $r['u_uid']; ?>)" name="Delete" value="Delete"></td>
             </tr>
 <!-- Javascript function for deleting data -->
 <script language="Javascript">
 function deleteme(delid)
 {
 if(confirm("Are you sure you want to Delete?")){
 window.location.href='crud/delete.php';
 }
 } 
 </script>
        <?php } ?>
    </table>
</div>
</body>

</html>

<?php

}else{

header("Location: http://motoko.sorainsurance.com.au"); 

}

?>

这会将它们带到 /update 文件。开头是这样的:

 <?php
 error_reporting();
 require_once('connect.php');
   $id = $_GET['id'];
   $SelSql = "SELECT * FROM `contact` WHERE id=$id";
   $res = mysqli_query($connection, $SelSql);
   $r = mysqli_fetch_assoc($res);

  if(isset($_POST) & !empty($_POST)){
    $name =  mysqli_real_escape_string($connection,$_POST['name']);
    $comp =  mysqli_real_escape_string($connection,$_POST['comp']);
    $title =  mysqli_real_escape_string($connection,$_POST['title']);
    $phone =  mysqli_real_escape_string($connection,$_POST['urstel']);
    $email =  mysqli_real_escape_string($connection,$_POST['email']);
    $location =  mysqli_real_escape_string($connection,$_POST['location']);


  $UpdateSql = "UPDATE `contact` SET Name='$name', Company='$comp', 
Title='$title', Phone='$phone', Email='$email', Address='$location' WHERE id=$id"; 

    $res = mysqli_query($connection, $UpdateSql);
   if($res){
     echo $smsg = "Successfully updated data.";
     echo  header('location: view.php');
   }else{
     echo $fmsg = "Failed to update data.";
    }
}

知道为什么错误不断弹出吗?如此困惑和努力进步:(

非常感谢!

404 错误代码表明,您的请求不正确 URL.

This would then take them to the /update file

您提到,请求将转到 update 文件,但是您的请求 URLcrud/update.php

现在,请求URL取决于文件的相关性。那么,您查看文件是否存在于根文件夹和 update.phpcrud 文件夹?

==已编辑==

(参考您的最新评论)看起来,您的 update.phpview.php 存在于同一文件夹中,那么您应该简单地更改请求

crud/update.php

update.php

您无需在请求中提及文件夹路径。