bakit kaya ganito error ko
Warning: Undefined array key "new-picture" in C:\xampp\htdocs\Innerjoin\user\profile.php on line 94
Warning: Trying to access array offset on value of type null in C:\xampp\htdocs\Innerjoin\user\profile.php on line 94
Warning: Undefined array key "new-picture" in C:\xampp\htdocs\Innerjoin\user\profile.php on line 98
Warning: Trying to access array offset on value of type null in C:\xampp\htdocs\Innerjoin\user\profile.php on line 98
Warning: Undefined array key "new-picture" in C:\xampp\htdocs\Innerjoin\user\profile.php on line 109
Warning: Trying to access array offset on value of type null in C:\xampp\htdocs\Innerjoin\user\profile.php on line 109
Warning: Undefined array key "new-picture" in C:\xampp\htdocs\Innerjoin\user\profile.php on line 110
Warning: Trying to access array offset on value of type null in C:\xampp\htdocs\Innerjoin\user\profile.php on line 110
Warning: Undefined array key "new-picture" in C:\xampp\htdocs\Innerjoin\user\profile.php on line 116
Warning: Trying to access array offset on value of type null in C:\xampp\htdocs\Innerjoin\user\profile.php on line 116
ito code ko :
<div class="mt-3">
<input class="form-control" type="text" name="old-picture" value="<?php echo $picture; ?>">
<label for="formFile" class="form-label ">Upload Image</label>
<input class="form-control" type="file" name="new-profile" onchange ="displayPreview(this.files)" id="formFile">
</div>
<center>
<span id="preview"></span>
</center>
<hr class="my-4">
<button class="w-100 mb-2 btn btn-sm btn-lg rounded-3 btn-primary" name= "update" type="submit">Update</button>
</div>
</div>
</form>
<?php
if (isset($_POST['update'])){
$user_id =$_POST ['user_id'];
$payee_name = $_POST['fname'];
$email_address = $_POST['email'];
$username = $_POST['nname'];
$password = $_POST['pword'];
$cpword = $_POST['cpword'];
$old_picture = $_POST['old-picture'];
$new_picture = $_FILES['new-picture']['name'];
if($new_picture !==''){
$update_filename = $_FILES['new-picture']['name'];
}
else {
$update_filename = $old_picture;
}
$mysqli_query = "UPDATE registration SET payee_name = '$payee_name', email_address = '$email_address', username = '$username', password = '$password', confirm_password = '$cpword', image = '$update_filename' WHERE user_id = '$user_id'";
$query_run =mysqli_query($con, $mysqli_query);
if ($query_run){
if($_FILES['new-picture']['name'] !==''){
$image_name = $_FILES['new-picture']['name'];
$exploded_array = explode('.',$image_name);
$ext = end($exploded_array);
$image_name = "Profile_picture".rand(000,999).'.'.$ext;
$source_path = $_FILES['new-picture']['tmp_name'];
$destination_path = "photo_folder/".$image_name;
$uploadOk = 1;
if ($uploadOk == 1) {
if (move_uploaded_file($source_path, $destination_path)) {
$file_path = mysqli_real_escape_string($con, $destination_path);
unlink("photo_folder/" .$old_picture);
}else{
} }}
}}
?>
Warning: Undefined array key "new-picture" in C:\xampp\htdocs\Innerjoin\user\profile.php on line 94
Warning: Trying to access array offset on value of type null in C:\xampp\htdocs\Innerjoin\user\profile.php on line 94
Warning: Undefined array key "new-picture" in C:\xampp\htdocs\Innerjoin\user\profile.php on line 98
Warning: Trying to access array offset on value of type null in C:\xampp\htdocs\Innerjoin\user\profile.php on line 98
Warning: Undefined array key "new-picture" in C:\xampp\htdocs\Innerjoin\user\profile.php on line 109
Warning: Trying to access array offset on value of type null in C:\xampp\htdocs\Innerjoin\user\profile.php on line 109
Warning: Undefined array key "new-picture" in C:\xampp\htdocs\Innerjoin\user\profile.php on line 110
Warning: Trying to access array offset on value of type null in C:\xampp\htdocs\Innerjoin\user\profile.php on line 110
Warning: Undefined array key "new-picture" in C:\xampp\htdocs\Innerjoin\user\profile.php on line 116
Warning: Trying to access array offset on value of type null in C:\xampp\htdocs\Innerjoin\user\profile.php on line 116
ito code ko :
<div class="mt-3">
<input class="form-control" type="text" name="old-picture" value="<?php echo $picture; ?>">
<label for="formFile" class="form-label ">Upload Image</label>
<input class="form-control" type="file" name="new-profile" onchange ="displayPreview(this.files)" id="formFile">
</div>
<center>
<span id="preview"></span>
</center>
<hr class="my-4">
<button class="w-100 mb-2 btn btn-sm btn-lg rounded-3 btn-primary" name= "update" type="submit">Update</button>
</div>
</div>
</form>
<?php
if (isset($_POST['update'])){
$user_id =$_POST ['user_id'];
$payee_name = $_POST['fname'];
$email_address = $_POST['email'];
$username = $_POST['nname'];
$password = $_POST['pword'];
$cpword = $_POST['cpword'];
$old_picture = $_POST['old-picture'];
$new_picture = $_FILES['new-picture']['name'];
if($new_picture !==''){
$update_filename = $_FILES['new-picture']['name'];
}
else {
$update_filename = $old_picture;
}
$mysqli_query = "UPDATE registration SET payee_name = '$payee_name', email_address = '$email_address', username = '$username', password = '$password', confirm_password = '$cpword', image = '$update_filename' WHERE user_id = '$user_id'";
$query_run =mysqli_query($con, $mysqli_query);
if ($query_run){
if($_FILES['new-picture']['name'] !==''){
$image_name = $_FILES['new-picture']['name'];
$exploded_array = explode('.',$image_name);
$ext = end($exploded_array);
$image_name = "Profile_picture".rand(000,999).'.'.$ext;
$source_path = $_FILES['new-picture']['tmp_name'];
$destination_path = "photo_folder/".$image_name;
$uploadOk = 1;
if ($uploadOk == 1) {
if (move_uploaded_file($source_path, $destination_path)) {
$file_path = mysqli_real_escape_string($con, $destination_path);
unlink("photo_folder/" .$old_picture);
}else{
} }}
}}
?>