我尝试在 m 网站中实现 CRUD,但我能够创建、读取和删除。然而,在开发Update功能的过程中出现了问题。谁能帮我?我将提供下面的代码。如果登录者是管理员,则该代码用于更新用户信息。谢谢。
<?php
// Include config file
require_once "config.php";
// Define variables and initialize with empty values
$firstname = $lastname = $email = $address = $status = $level = "";
$firstname_err = $lastname_err = $email_err = $address_err = $level_err = $status_err = "";
// Processing form data when form is submitted
if(isset($_POST["id"])){
// Get hidden input value
$id = $_POST["id"];
// Validate name-first
$input_firstname = trim($_POST["firstname"]);
if(empty($input_firstname)){
$firstname_err = "Please enter a first name.";
} elseif(!filter_var($input_firstname, FILTER_VALIDATE_REGEXP, array("options"=>array("regexp"=>"/^[a-zA-Z\s]+$/")))){
$firstname_err = "Please enter a valid first name.";
} else{
$firstname = $input_firstname;
}
//Validate lastname
$input_lastname = trim($_POST["lastname"]);
if(empty($input_lastname)){
$lastname_err = "Please enter a last name.";
} elseif(!filter_var($input_lastname, FILTER_VALIDATE_REGEXP, array("options"=>array("regexp"=>"/^[a-zA-Z\s]+$/")))){
$lastname_err = "Please enter a valid last name.";
} else{
$lastname = $input_firstname;
}
//Validate email address
$input_email = trim($_POST["email"]);
if(empty($input_email)){
$email_err = "Please enter an email address.";
} else{
$email = $input_email;
}
// Validate address
$input_address = trim($_POST["address"]);
if(empty($input_address)){
$address_err = "Please enter an address.";
} else{
$address = $input_address;
}
潇潇雨雨
哔哔one
慕村9548890