aggiornamento tabella user e tabella messaggio

  • Creatore Discussione Creatore Discussione Imperor
  • Data di inizio Data di inizio

Imperor

Utente Attivo
25 Nov 2010
102
2
18
Roma
www.fcfclean.it
Buongiorno e ben ritrovati come posso aggiornare anche la tabella message quando un utente cambia la foto profilo vorrei che aggiorni anche la la tabella message
Codice:
 <?php
                                // Include the database configuration file
                                include_once 'conn.php';
                               
                                $statusMsg = '';

                                // File upload directory
                                $targetDir = "image/";
                                  $email = $_SESSION['email'];
                                if(isset($_POST["submit"])){
                                    if(!empty($_FILES["image"]["name"])){
                                        $fileName = basename($_FILES["image"]["name"]);
                                        $targetFilePath = $targetDir . $fileName;
                                        $fileType = pathinfo($targetFilePath,PATHINFO_EXTENSION);
                                   
                                        // Allow certain file formats
                                        $allowTypes = array('jpg','png','jpeg','gif');
                                        if(in_array($fileType, $allowTypes)){
                                            // Upload file to server
                                            if(move_uploaded_file($_FILES["image"]["tmp_name"], $targetFilePath)){
                                                // Insert image file name into database
                                                $insert = $conn->query("UPDATE user SET image='$fileName' WHERE email='$email'");
                                                $insert = $conn->query("UPDATE message SET image='$fileName' WHERE email='$email'");
                                                if($insert){
                                                    $statusMsg = "The file ".$fileName. " has been uploaded successfully.";
                                                     header("Location: profilo2.php");
                                                }else{
                                                    $statusMsg = "File upload failed, please try again.";
                                                }
                                            }else{
                                                $statusMsg = "Sorry, there was an error uploading your file.";
                                            }
                                        }else{
                                            $statusMsg = 'Sorry, only JPG, JPEG, PNG, & GIF files are allowed to upload.';
                                        }
                                    }else{
                                        $statusMsg = 'Please select a file to upload.';
                                    }
                                }
                               
                                // Display status message
                                echo $statusMsg;
                                ?>
 
Ultima modifica:
Buongiorno e ben ritrovati come posso aggiornare anche la tabella message quando un utente cambia la foto profilo vorrei che aggiorni anche la la tabella message
Codice:
 <?php
                                // Include the database configuration file
                                include_once 'conn.php';
                              
                                $statusMsg = '';

                                // File upload directory
                                $targetDir = "image/";
                                  $email = $_SESSION['email'];
                                if(isset($_POST["submit"])){
                                    if(!empty($_FILES["image"]["name"])){
                                        $fileName = basename($_FILES["image"]["name"]);
                                        $targetFilePath = $targetDir . $fileName;
                                        $fileType = pathinfo($targetFilePath,PATHINFO_EXTENSION);
                                  
                                        // Allow certain file formats
                                        $allowTypes = array('jpg','png','jpeg','gif');
                                        if(in_array($fileType, $allowTypes)){
                                            // Upload file to server
                                            if(move_uploaded_file($_FILES["image"]["tmp_name"], $targetFilePath)){
                                                // Insert image file name into database
                                                $insert = $conn->query("UPDATE user SET image='$fileName' WHERE email='$email'");
                                                $insert = $conn->query("UPDATE message SET image='$fileName' WHERE email='$email'");
                                                if($insert){
                                                    $statusMsg = "The file ".$fileName. " has been uploaded successfully.";
                                                     header("Location: profilo2.php");
                                                }else{
                                                    $statusMsg = "File upload failed, please try again.";
                                                }
                                            }else{
                                                $statusMsg = "Sorry, there was an error uploading your file.";
                                            }
                                        }else{
                                            $statusMsg = 'Sorry, only JPG, JPEG, PNG, & GIF files are allowed to upload.';
                                        }
                                    }else{
                                        $statusMsg = 'Please select a file to upload.';
                                    }
                                }
                              
                                // Display status message
                                echo $statusMsg;
                                ?>
Risolto ero convinto che non avrebbe funzionato ho postato senza fare dei test
 
ciao e buon pomeriggio come posso visualizzare la lista degli utenti registrati in orizontale?
Codice:
<div id="utenti"></div></div></div>
                                         <script>
                                    $(document).ready(function() {
                                        $.ajax({
                                            url: 'memberlist.php',
                                            type: 'GET',
                                            dataType: 'json',
                                            success: function(data) {
                                                data.forEach(function(utente) {
                                                    $('#utenti').append('<img src="image/' + utente.image + '" class="img-circle img-user img-thumbnail" height="50px;" width="50px;""><p>' + utente.name + '</p>');
                                                });
                                            },
                                            error: function() {
                                                console.log('Errore nel recupero degli utenti.');
                                            }
                                        });
                                    });
                                </script>
 
ciao e buon pomeriggio come posso visualizzare la lista degli utenti registrati in orizontale?
Codice:
<div id="utenti"></div></div></div>
                                         <script>
                                    $(document).ready(function() {
                                        $.ajax({
                                            url: 'memberlist.php',
                                            type: 'GET',
                                            dataType: 'json',
                                            success: function(data) {
                                                data.forEach(function(utente) {
                                                    $('#utenti').append('<img src="image/' + utente.image + '" class="img-circle img-user img-thumbnail" height="50px;" width="50px;""><p>' + utente.name + '</p>');
                                                });
                                            },
                                            error: function() {
                                                console.log('Errore nel recupero degli utenti.');
                                            }
                                        });
                                    });
                                </script>
ho risolto :)
Codice:
<div id="users-container"></div>
                                         <script>
                                        $(document).ready(function() {
                                            $.ajax({
                                                url: 'listautenti.php',
                                                type: 'GET',
                                                dataType: 'json',
                                                success: function(data) {
                                                    var usersContainer = $('#users-container');
                                                    
                                                    $.each(data, function(index, user) {
                                                        usersContainer.append('<div style="display: inline-block; margin: 10px;">' +
                                                            '<img src="image/' + user.image + '" alt="' + user.name + '" style="width: 100px; height: 100px;">' +
                                                            '<p>' + user.name + '</p>' +
                                                            '</div>');
                                                    });
                                                },
                                                error: function(xhr, status, error) {
                                                    console.error('Error: ' + error);
                                                }
                                            });
                                        });
                                        </script>
 

Discussioni simili