-
Profile Editing.
PHP Code:
<?php
if(isset($_POST["update"]))
{
//echo'<pre>';print_r($_POST);exit();
//$user_name =$_POST["name"];
$conn = mysqli_connect("localhost", "root", "", "videos") or die("Connection to Server failed!" . mysqli_error());
$query = mysqli_query("SELECT * from users WHERE Id='$_POST[Id]'");
$username = $_Get[$query('Username')];
$email = $_Get[$query('Email')];
$employee = $_Get[$query('EmployeeID')];
$designation = $_Get[$query('Designation')];
$password = $_Get[$query('Password')];
$id =$_Get['Id'];
// Connect to server and select database.
// $conn = mysqli_connect("localhost", "root", "", "videos") or die("Connection to Server failed!" . mysqli_error());
// $selet = mysqli_select_db("first_db", "root", "") or die("Cannot connect to database");
//echo $query;exit();
$result = mysqli_query($query);
$rows = mysqli_num_rows($result);
// //echo'USER EXIST';
if ($rows==$id)
{
while($rs = mysqli_fetch_array($result))
{
$username = $rs["Username"];
$email = $rs["Email"];
$employee =$rs["EmployeeID"];
$designation=$rs["Designation"];
$password=$rs["Password"];
}
}
$query = mysqli_query($conn, "UPDATE users SET Username='$name', Email='$email', EmployeeID='$employee', Designation='$designation', Password='$password' WHERE Id='$id'");
$result = mysqli_query($query);
if($result==false)
{
die(mysqli_error());
}
header("Location: settings.php");
return mysqli_affected_rows();
//echo'<pre>';print_r($result);exit();
exit();
}
?>
This is my php code for profile editing of users by admin. I have added "value" element in expected fields my html form. But still I am unable to fetch the data into those form fields. for example, I am getting following error in expected field:
Code:
<br /><b>Notice</b>: Undefined variable: username in <b>C:\xampp\htdocs\VS\edit.php</b> on line <b>120</b><br />
I am fresher for php. I hope that I will get solution immidiately from experts in this forum.
Thank You,