Sunday, 14 May 2017

php - How to fix Notice: Undefined index in PDO

Answer


Answer





i have




Notice: Undefined index: _ava in C:\xampp\htdocs\otakutangerang_admin\edit_user.phpon line 26



 $avatar = $_POST['_ava'];


Notice: Undefined index: _skill in C:\xampp\htdocs\otakutangerang_admin\edit_user.php on line 27



$usr_skill = $_POST['_skill'];



and this my code



  if (isset($_POST['update'])) {

$id = $_GET['id'];
$email = $_POST['_em'];
$fname = $_POST['_fn'];
$lname = $_POST['_ln'];
$web_usr = $_POST['_web'];
$usr_note = $_POST['_note'];

$avatar = $_POST['_ava'];
$usr_skill = $_POST['_skill'];

//Retrieve the user account information by id.
if ($object->Update($id, $email, $fname, $lname, $web_usr, $usr_note, $avatar, $usr_skill)) {
$msg = "
WOW! Record was updated successfully HOME!
";
} else {
$msg = "
SORRY! ERROR while updating record !
";
}
}


if (isset($_GET['id'])) {
$id = $_GET['id'];
extract($object->Details($id));
}


This my form to change and edit the database



    








You require permission from Administrators to change it.























































You require permission from Administrators to change it.























Answer



use isset()



$avatar = isset($_POST['_ava']) ? $_POST['_ava'] : null;


$usr_skill = isset($_POST['_skill']) ? $_POST['_skill'] : null;


and same other post value . hope it will help you



for more information



http://php.net/manual/en/function.isset.php


No comments:

Post a Comment

c++ - Does curly brackets matter for empty constructor?

Those brackets declare an empty, inline constructor. In that case, with them, the constructor does exist, it merely does nothing more than t...