How can i resolve my problem with the header function in php

I have a problem with the "header" function in php. What I want to do is a profile picture system. everything works, apart from my header.

My php / html code :

                    <div class="configFormContent">
                        <form method="post" enctype="multipart/form-data" class="configForm">
                            <input type="button" name="SelectPicture" class="btnChoosePicture" value="Choisir une photo">
                            <input type="text" name="Pseudo" class="inputConfigForm" placeholder="Pseudo" required>
                            <input type="text" name="Name" class="inputConfigForm" placeholder="Name" value="<?= $userInfo['Name']; ?>" required>
                            <input type="text" name="Surname" class="inputConfigForm" placeholder="Surname" value="<?= $userInfo['Surname']; ?>" required>
                            <!--Line 110-->
                            <input type="text" name="Age" class="inputConfigForm" placeholder="Age" value="<?= $userInfo['Age']; ?>" required>
                            <input type="text" name="Ville" class="inputConfigForm" placeholder="Ville" required>
                            <input type="text" name="Pays" class="inputConfigForm" placeholder="Pays" required>
                            <textarea name="Bio" class="textareaFormConfig" cols="30" rows="5"></textarea>
                            <input type="submit" name="submitConfigForm" class="submitConfigForm" value="Valider le profil">
                        </form>
                    </div>
                </div>
                <div class="passConfigFormContent">
                    <a href="#" class="passConfigForm">Passer</a>
                </div>
            </div>
        </div>
        <div class="pictureValidationContent">
            <div class="pictureValidation">
                <div class="titlePictureValidationContent">                            
                    <h1 class="titlePictureValidationContent">
                        Choisir la photo de profil
                    </h1>
                </div>
                <div class="pictureInputValidationContent">
                    <p class ="titleInputPictureValidation">
                        Parcourir : 
                        <button class="cancelSelectPicture">
                            Annuler
                        </button>
                    </p>
                    <form method="post" enctype="multipart/form-data" class="formPictureValidation">
                        <input type="file" name="Picture" class="Picture">
                        <input type="submit" name="submitPictureValidation" value="Valider la photo de profil" class="pictureValidationSubmit">
                    </form>
                    <?php
                        if(isset($_FILES['Picture']) && !empty($_FILES['Picture']['name']))
                        {
                            $maxSize = 2097152;
                            $extentionsValides = array('jpg', 'jpeg', 'gif', 'png');
   
                            if($_FILES['Picture']['size'] <= $maxSize)
                            {
                                $extentionUpload = strtolower(substr(strrchr($_FILES['Picture']['name'], '.'), 1));
                                if(in_array($extentionUpload, $extentionsValides))
                                {
                                    $chemin = '../Config/Membre/Avatars/'.$_SESSION['id'].".".$extentionUpload;
                                    $resultat = move_uploaded_file($_FILES['Picture']['tmp_name'], $chemin);

                                    if($resultat)
                                    {
                                        $updatePicture = $pdo->prepare('UPDATE users SET Picture = :Picture WHERE id = :id');
                                        $updatePicture->execute([
                                            'Picture' => $_SESSION['id'].".".$extentionUpload,
                                            'id' => $_SESSION['id']
                                        ]);
                                        //That's the header I'm having trouble with
                                        header('Location:ProfileConfiguration.php?id='.$_SESSION['id']);
                                    }

So what I want to do, is enter the image the user wants in the database and then make a header on their page so that the image appears. I know echo can be a problem because it's an exit and the headers don't execute after an exit. But I don't know how to solve the problem, that's why I appealed to you.

A picture of my error message :

Error message From php

(all the braces close lower but the code is not interesting for my problem).

Thanks for your help

And sorry for my English i'm a begginer ;)



Read more here: https://stackoverflow.com/questions/68476785/how-can-i-resolve-my-problem-with-the-header-function-in-php

Content Attribution

This content was originally published by Emilien Charpié at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: