<?php
$servername = "localhost";
$username = "username";
$password = "password";
$dbname = "database_name";
// Create connection
$conn = mysqli_connect($servername, $username, $password, $dbname);
// Check connection
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}
echo "Connected successfully";
?>
Connected successfully<?php $servername = "localhost"; $username = "username"; $password = "password"; $dbname = "database_name"; // Create connection $conn = mysqli_connect($servername, $username, $password, $dbname); // Check connection if (!$conn) { die("Connection failed: " . mysqli_connect_error()); } echo "Connected successfully"; ?>
The error message "Unknown column 'Designation' in 'field list'" suggests that the column 'Designation' does not exist in the table 'tblaccounts' in your MySQL database.Connected successfully
Warning: Undefined array key "username" in C:\xampp\htdocs\inven-it\buy\lg.php on line 6
Fatal error: Uncaught mysqli_sql_exception: Unknown column 'Designation' in 'field list' in C:\xampp\htdocs\inven-it\buy\lg.php:10 Stack trace: #0 C:\xampp\htdocs\inven-it\buy\lg.php(10): mysqli->prepare('SELECT id, user...') #1 {main} thrown in C:\xampp\htdocs\inven-it\buy\lg.php on line 10
<?php
session_start();
require_once 'conenct.php';
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$username = $_POST["username"];
$password = $_POST["password"];
$sql = "SELECT id, username, Pass, Fullname, Department, Designation FROM tblaccounts WHERE username = ?";
$stmt = $conn->prepare($sql);
$stmt->bind_param("s", $username);
$stmt->execute();
$stmt->store_result();
if ($stmt->num_rows > 0) {
$stmt->bind_result($id, $username, $hashed_password, $fullname, $department, $designation);
$stmt->fetch();
if (password_verify($password, $hashed_password)) {
$_SESSION["loggedin"] = true;
$_SESSION["id"] = $id;
$_SESSION["username"] = $username;
$_SESSION["fullname"] = $fullname;
$_SESSION["department"] = $department;
$_SESSION["designation"] = $designation;
header("location: index.php");
} else {
echo "Invalid username or password.";
}
} else {
echo "Invalid username or password.";
}
$stmt->close();
}
$conn->close();
?>
how to fix this error
how to fix?The error message "Unknown column 'Designation' in 'field list'" suggests that the column 'Designation' does not exist in the table 'tblaccounts' in your MySQL database.
Make sure that you have spelled the column name correctly and that it exists in the table. Check the spelling and make sure that the column is included in the SQL query that you are using to retrieve data from the table.
Also, the warning "Undefined array key 'username'" suggests that the value of the 'username' key in the $_POST array is not set. Make sure that the 'name' attribute of the username input field in the HTML form matches the 'username' key in the $_POST array in the PHP code.
To fix the "Unknown column 'Designation' in 'field list'" error, you need to ensure that the column named "Designation" exists in the table named "tblaccounts" in your MySQL database. If the column does not exist, you need to add it to the table.how to fix?
<input type="text" name="user" placeholder="Username">
$username = $_POST["username"];
$username = $_POST["user"];
Fatal error: Uncaught mysqli_sql_exception: Unknown column 'Designation' in 'field list' in C:\xampp\htdocs\inven-it\buy\lg.php:10 Stack trace: #0 C:\xampp\htdocs\inven-it\buy\lg.php(10): mysqli->prepare('SELECT id, user...') #1 {main} thrown in C:\xampp\htdocs\inven-it\buy\lg.php on line 10To fix the "Unknown column 'Designation' in 'field list'" error, you need to ensure that the column named "Designation" exists in the table named "tblaccounts" in your MySQL database. If the column does not exist, you need to add it to the table.
To fix the "Undefined array key 'username'" warning, you need to ensure that the 'name' attribute of the username input field in the HTML form matches the 'username' key in the $_POST array in the PHP code.
For example, if your username input field in the HTML form looks like this:
Code:<input type="text" name="user" placeholder="Username">
Then you need to change this line in your PHP code:
Code:$username = $_POST["username"];
to:
Code:$username = $_POST["user"];
This will ensure that the value of the 'username' key in the $_POST array is set and the warning message is not generated.
The error "Unknown column 'Designation' in 'field list'" is likely caused by the fact that the column named "Designation" does not exist in the table "tblaccounts" in your MySQL database.Fatal error: Uncaught mysqli_sql_exception: Unknown column 'Designation' in 'field list' in C:\xampp\htdocs\inven-it\buy\lg.php:10 Stack trace: #0 C:\xampp\htdocs\inven-it\buy\lg.php(10): mysqli->prepare('SELECT id, user...') #1 {main} thrown in C:\xampp\htdocs\inven-it\buy\lg.php on line 10
this is the code of in line 10
$stmt = $conn->prepare($sql);
can you fix this?
ALTER TABLE tblaccounts ADD Designation VARCHAR(255);
$sql = "SELECT id, username, Pass, Fullname, Department, Designation FROM tblaccounts WHERE username = ?";
here is my codeThe error "Unknown column 'Designation' in 'field list'" is likely caused by the fact that the column named "Designation" does not exist in the table "tblaccounts" in your MySQL database.
To fix this, you will need to add a column named "Designation" to the "tblaccounts" table in your MySQL database. You can do this using SQL by running a query like the following:
Code:ALTER TABLE tblaccounts ADD Designation VARCHAR(255);
This will add a new column named "Designation" to the "tblaccounts" table with a data type of VARCHAR(255).
Once you have added the column, you should update the SQL query in your PHP code to include the new column. For example:
Code:$sql = "SELECT id, username, Pass, Fullname, Department, Designation FROM tblaccounts WHERE username = ?";
Make sure that the spelling and case of the column name in the SQL query matches the spelling and case of the column name in the MySQL database.
The error "Undefined array key 'Pass'" is caused by the fact that the input field in the HTML form is named "password" but you are trying to access it using the key "Pass" in the PHP code. To fix this warning, you should change the following line of code:here is my code
<?php
session_start();
require_once 'conenct.php';
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$username = $_POST["user"];
$Pass = $_POST["Pass"];
$sql = "SELECT id, username, Pass, Fullname, Department, Disgnation FROM tblaccounts WHERE username = ?";
$stmt = $conn->prepare($sql);
$stmt->bind_param("s", $username);
$stmt->execute();
$stmt->store_result();
if ($stmt->num_rows > 0) {
$stmt->bind_result($id, $username, $Pass, $fullname, $department, $Disgnation);
$stmt->fetch();
if (password_verify($Pass)) {
$_SESSION["loggedin"] = true;
$_SESSION["id"] = $id;
$_SESSION["username"] = $username;
$_SESSION["fullname"] = $fullname;
$_SESSION["department"] = $department;
$_SESSION["Disgnation"] = $Disgnation;
header("location: index.php");
} else {
echo "Invalid username or password.";
}
} else {
echo "Invalid username or password.";
}
$stmt->close();
}
$conn->close();
?>
here is my error
Warning: Undefined array key "Pass" in C:\xampp\htdocs\inven-it\buy\lg.php on line 7
Fatal error: Uncaught ArgumentCountError: password_verify() expects exactly 2 arguments, 1 given in C:\xampp\htdocs\inven-it\buy\lg.php:19 Stack trace: #0 C:\xampp\htdocs\inven-it\buy\lg.php(19): password_verify(Object(SensitiveParameterValue)) #1 {main} thrown in C:\xampp\htdocs\inven-it\buy\lg.php on line 19
can you fix this?
$Pass = $_POST["Pass"];
$Pass = $_POST["password"];
if (password_verify($Pass)) {
if (password_verify($Pass, $hashed_password)) {
invalid password errorThe error "Undefined array key 'Pass'" is caused by the fact that the input field in the HTML form is named "password" but you are trying to access it using the key "Pass" in the PHP code. To fix this warning, you should change the following line of code:
Code:$Pass = $_POST["Pass"];
to:
Code:$Pass = $_POST["password"];
The error "password_verify() expects exactly 2 arguments, 1 given" is caused by the fact that the password_verify() function requires two arguments: the plain password string and the hashed password string. You are passing only one argument to the function. To fix this error, you should change the following line of code:
Code:if (password_verify($Pass)) {
to:
Code:if (password_verify($Pass, $hashed_password)) {
where "$hashed_password" is the hashed password retrieved from the database.
Also, in your SQL query, there is a spelling mistake in the column name "Disgnation". It should be "Designation".
dbinventittblaccountstblaccounts (Id int(11) NOT NULL,username varchar(255) DEFAULT NULL,Pass varchar(255) DEFAULT NULL,Fullname varchar(255) DEFAULT NULL,Department varchar(255) DEFAULT NULL,Disgnation varchar(255) DEFAULT NULL,datecreated timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMPtblaccountstblaccounts (Id, username, Pass, Fullname, Department, Disgnation, datecreated) VALUEStblaccountstblaccountsId);tblaccountstblaccountsId int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;