Hi Team
I think i am passing incorrect details from my form to the back end. the fields have current to the table 'password_reset'(id, new_password, confirm_password, otp, created at and timestamp). But now i am getting some undefined array key 'otp, email, conn.
// forgot_password
Reset Password
// otp-confirmation.php
prepare($sql);
$stmt->bind_param("ss", $newPassword, $email);
$stmt->execute();
$stmt->close();
// rest of other code below
?>
Rajkiran SwainPosted May 5, 2023, 4:50 AM
It looks like you are getting an "undefined array key" error for "otp", "email", and "conn" variables in your PHP script. This is likely because you are not passing these variables in your form or you are not properly initializing them before using them in your script.
In your form, you only have fields for "email", "new-password", and "confirm-password", but not for "otp". You need to add a field for "otp" in your form so that it can be submitted to the PHP script. You can add this field using the following code:
```
```
Make sure to include this code in your form before the submit button.
In addition, it looks like you are using an undefined variable "$conn" in your PHP script. This variable is likely your database connection object, so make sure to properly initialize it before using it in your script. You can initialize this variable using the following code:
```
// Include the database connection file
require_once "dbconn.php";
// Create a new database connection object
$conn = new mysqli(DB_HOST, DB_USER, DB_PASS, DB_NAME);
// Check for any errors with the connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
```
Make sure to replace "DB_HOST", "DB_USER", "DB_PASS", and "DB_NAME" with your own database connection information.
Once you have added the "otp" field to your form and properly initialized the "$conn" variable, the "undefined array key" errors should go away.
Guest UserPosted May 5, 2023, 6:27 AM
Hi Rajkiran
Thanks for giving me enough clarity let me amend my form to have all those fields in, so i wont get those and try to either use pdo to connect to my db.