尝试使用员工ID(emp_id)更新员工信息。
我在下面编写了更新查询。我已经检查了表名并 数据库详细信息全部正确,但由于某种原因更新查询不正确 运行。
有什么方法可以解决这个问题?
<?php
session_start();
$id=$_SESSION['SESS_MEMBER_ID'];
//echo $id;
require_once('auth.php');
include('connection.php');
?>
<?php
$query2="SELECT * FROM add_employee where emp_id='$id'";
$result1=mysqli_query($conn, $query2);
while($row=mysqli_fetch_array($result1))
{
fullname=$row['fullname'];
$email=$row['email'];
$contact=$row['contact'];
$address=$row['address'];
$designation=$row['designation'];
//$client_name=$row['client_name'];
$joining_date=$row['joining_date'];
$password=$row['password'];
//$aadhartoupload=$row['aadhar'];
$filetoupload=$row['photo'];
//$resumetoupload=$row['resume'];
}
//die();
?>
获取员工信息
<?php
if(isset($_POST['submit'])){
$fullname=$_POST['fullname'];
$email=$_POST['email'];
$contact=$_POST['contact'];
$address=$_POST['address'];
$designation=$_POST['designation'];
//$client_name=$_POST['client_name'];
$joining_date=$_POST['joining_date'];
$password=$_POST['password'];
员工信息更新查询
$sqlq= "UPDATE add_employee SET
fullname='$fullname',
email='$email',
contact='$contact',
address='$address',
designation='$designation',
joining_date='$joining_date',
password='$password'
WHERE
emp_id=$id";
$sqlqry= mysqli_query( $sqlq, $conn );
if ($sqlqry) {
echo "<script type='text/javascript'>alert('Successful - Record Updated!'); window.location.href = 'user_profile.php';</script>";
} else {
echo "<script type='text/javascript'>alert('Unsuccessful - ERROR!'); window.location.href = 'user_dashboard.php';</script>";
}
}
?>
<!-- end of update profile code!-->
<form action="user_profile.php" method="post" enctype="multipart/form-data">
<div class="row">
<div class="col-md-3">
<div class="form-group">
<label>EMP ID</label>
<input type="text" class="form-control border-input" id="emp_id" name="emp_id" placeholder="Employee Id" value="<?php echo $id; ?>" disabled>
</div>
</div>
<div class="col-md-4">
<div class="form-group">
<label>Fullname</label>
<input type="text" class="form-control border-input" id="fullname" name="fullname" placeholder="fullname" value="<?php echo $fullname; ?>">
</div>
</div>
<div class="col-md-5">
<div class="form-group">
<label>Email address</label>
<input type="email" class="form-control border-input" name="email" placeholder="email" value="<?php echo $email; ?>">
</div>
</div>
</div>
<div class="row">
<div class="col-md-3">
<div class="form-group">
<label>Contact number</label>
<input type="text" class="form-control border-input" name="contact"placeholder="Contact" value="<?php echo $contact; ?>">
</div>
</div>
<div class="col-md-4">
<div class="form-group">
<label for="exampleInputEmail1">Designation</label>
<input type="text" class="form-control border-input" name="designation" placeholder="Your Designation" value="<?php echo $designation; ?>" disabled>
</div>
</div>
<div class="col-md-5">
<div class="form-group">
<label>Client Name</label>
<input type="text" class="form-control border-input" name="client_name" placeholder="Client Name" value="<?php echo $client_name; ?>" disabled>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<div class="form-group">
<label>Address</label>
<input type="text" class="form-control border-input" name="address" placeholder="Address" value="<?php echo $address; ?>">
</div>
</div>
</div>
<div class="row">
<div class="col-md-6">
<div class="form-group">
<label>Joining Date</label>
<input type="text" class="form-control border-input" name="joining_date" placeholder="Joining Date" value="<?php echo $joining_date; ?>" disabled>
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label>Change password</label>
<input type="password" class="form-control border-input" name="password" placeholder="Country" value="<?php echo $password; ?>">
</div>
</div>
</div>
<div class="row">
<!--<div class="col-md-4">
<div class="form-group">
<label>Upload Aadhar</label>
<input type="file" name="aadhar" id="aadhar" value="<?php //echo $aadhartoupload; ?>" >
</div>
</div>!-->
<div class="col-md-4">
<div class="form-group">
<label>Upload photo</label>
<input type="file" name="photo" id="photo" value="<?php echo $filetoupload; ?>" >
</div>
</div>
<!--<div class="col-md-4">
<div class="form-group">
<label>Upload Resume</label>
<input type="file" name="resume" id="resume" value="<?php //echo $resumetoupload; ?>" >
</div>
</div>!-->
</div>
<div class="text-center">
<!--class="btn btn-info btn-fill btn-wd"!-->
<button type="submit" name="submit" class="btn btn-info btn-fill btn-wd">Update Profile</button>
</div>
<div class="clearfix"></div>
</form>
答案 0 :(得分:-1)
我认为您需要检查WHERE emp_id=$id
附近的sql语句。尝试使用WHERE emp_id='$id'
。这些引号可能会有所不同。