Navigazione

    Privacy - Termini e condizioni
    © 2020 Search On Media Group S.r.l.
    • Registrati
    • Accedi
    • CATEGORIES
    • Discussioni
    • Non letti
    • Recenti
    • Hashtags
    • Popolare
    • Utenti
    • Stream
    • Interest
    • Categories
    1. Home
    2. imperor
    3. Post
    I

    imperor

    @imperor

    • Profilo
    • Chi segue 0
    • Da chi è seguito 0
    • Discussioni 56
    • Post 137
    • Migliore 2
    • Gruppi 0
    Iscrizione Ultimo Accesso
    Sito Internet www.fcfclean.it Località Roma Età 57
    2
    Reputazione
    137
    Post
    0
    Visite al profilo
    0
    Da chi è seguito
    0
    Chi segue
    User Attivo

    Post creati da imperor

    • codice non funzionante

      Buongiorno ho trovato questo codice ma non funziona più ho provato a fare delle modifiche con esito negativo chiedo aiuto grazie

      <script>
      	
      function getText() {
      		
      	var $a =	document.getElementById('text').value;
      	
      		xhr = new XMLHttpRequest();
      		xhr.open('POST' , 'chatdb.php',true);
      		xhr.setRequestHeader('content-type','application/x-www-form-urlencoded');
      		xhr.send('chat='+$a);
      		xhr.onreadystatechange=function(){
      			if (xhr.responseText){
      			//	document.getElementById('chatarea').innerHTML=xhr.responseText;
      									}
      				}
      					}
      		
      
      function setText(){
      	
      	xhr = new XMLHttpRequest();
      	xhr.open('POST' , 'chatFetch.php' , true);
      	xhr.setRequestHeader('content-type','application/x-www-form-urlencoded');
      	xhr.send();
      	xhr.onreadystatechange = function(){
      	//	alert(xhr.responseText);
      			document.getElementById('chatarea').innerHTML = xhr.responseText;
      			}
      		
      	}
      	setInterval("setText()",2000);
      	
      	
      setInterval("users()",3000);
      
      	
      	function users(){
      	xhr1 = new XMLHttpRequest();
      	xhr1.open('POST' , 'userFetch.php' , true);
      	xhr1.setRequestHeader('content-type','application/x-www-form-urlencoded');
      	xhr1.send();
      	xhr1.onreadystatechange = function(){
      	//	alert(xhr.responseText);
      			document.getElementById('loginperson').innerHTML = xhr1.responseText;
      			}
      		
      		
      		}
      		
      		
      </script>
      
      postato in Coding
      I
      imperor
    • RE: login con password verify

      risolto con un altro codice 🙂

      postato in Coding
      I
      imperor
    • login con password verify

      salve e ben ritrovati 😀 ho un problema non riesco a far funzionare il login con la password verify dove sbaglio? posto il codice

      <?php
          require('db.php');
          session_start();
          // When form submitted, check and create user session.
          if (isset($_POST['username'])) {
              $username = stripslashes($_REQUEST['username']);    // removes backslashes
              $username = mysqli_real_escape_string($con, $username);
              $password = stripslashes($_REQUEST['password']);
              $password = '$password'; // password inserita dall'utente nel login
      		if (password_verify($password, $password)) {
      			
      		}
              // Check user is exist in the database
              $query    = "SELECT * FROM `users` WHERE username='$username'
                           AND password='$password'";
              $result = mysqli_query($con, $query) or die(mysql_error());
              $rows = mysqli_num_rows($result);
              if ($rows == 1) {
                  $_SESSION['username'] = $username;
                  // Redirect to user dashboard page
                  header("Location: dashboard.php");
              } else {
                  echo "<div class='form'>
                        <h3>Incorrect Username/password.</h3><br/>
                        <p class='link'>Click here to <a href='login.php'>Login</a> again.</p>
                        </div>";
              }
          } else {
      ?>
          <form class="form" method="post" name="login">
              <h1 class="login-title">Login</h1>
              <input type="text" class="login-input" name="username" placeholder="Username" autofocus="true"/>
              <input type="password" class="login-input" name="password" placeholder="Password"/>
              <input type="submit" value="Login" name="submit" class="login-button"/>
              <p class="link">Don't have an account? <a href="registration.php">Registration Now</a></p>
        </form>
      
      postato in Coding
      I
      imperor
    • RE: texarea quando si invia il testo emette un suono

      @giulio-marchesi ha detto in texarea quando si invia il testo emette un suono:

      <script> function f(){ const suono = new Audio("nomefile.mp3"); suono.play(); } </script>

      buongiorno e grazie per la risposta meglio javascript 🙂

      postato in Coding
      I
      imperor
    • RE: texarea quando si invia il testo emette un suono

      @merlinox ciao ho usato chatGPT 🙂 e mi ha generato funziona alla grande! l'ho inserito nel file dove salva i messaggi sul daatabase

       <?php
      		$myAudioFile = "suoni/whisper.wav";
      		echo '<audio autoplay="true" style="display:none;">
      		<source src="'.$myAudioFile.'" type="audio/wav">
      		</audio>';
      		?>
      
      postato in Coding
      I
      imperor
    • RE: texarea quando si invia il testo emette un suono

      @merlinox grazie

      postato in Coding
      I
      imperor
    • texarea quando si invia il testo emette un suono

      ciao a tutti 🙂 come posso fare in modo che quando un utente scrive nella texarea al clik emette un suono?

      postato in Coding
      I
      imperor
    • RE: accesso utente

      Buongiorno sono riuscito a risolvere certo non è un gran che ma va bene e funziona 🙂 posto il codice

      <?php
          session_start();
          include('../db.conn.php');
          if (isset($_POST['username'])) {
              $username = $_POST['username'];
              $password = $_POST['password'];
              $query = $conn->prepare("SELECT * FROM users WHERE username=:username");
              $query->bindParam("username", $username, PDO::PARAM_STR);
              $query->execute();
              $result = $query->fetch(PDO::FETCH_ASSOC);
              if (!$result) {
                 
      		$em = "Il nome utente non risulta registrato!";
          	header("Location: ../../index.php?error=$em");
      			
              } else {
                  if (password_verify($password, $result['password'])) {
                      $_SESSION['user_id'] = $result['user_id'];
      				$_SESSION['username'] = $result['username'];
      				$_SESSION['name'] = $result['name'];
      				
      				header("Location: ../../home.php");
      				
                      echo '<p class="success">Accesso eseguito con successo!</p>';
                  } else {
                      $em = "Nome utente o password errata!";
          	    header("Location: ../../index.php?error=$em");
                  }
              }
          }
      ?>
      
      postato in Coding
      I
      imperor
    • accesso utente

      salve non riesco a capire perchè se un utente non registrato prova a effettuare l'accesso da pagina bianca come posso risolvere? chiedo aiuto posto i codici

      <form method="post" 
      			action="app/http/auth.php">
                  <div class="d-flex
      			justify-content-center
      			align-items-center
      			flex-column">
      			<h3 class="display-4 fs-1 
      			text-center">
      			</h3>   
      
      			</div>
      			<?php if (isset($_GET['error'])) { ?>
      			<div class="alert alert-warning" role="alert">
      			<?php echo htmlspecialchars($_GET['error']);?>
      			</div>
      			<?php } ?>
      										
      			<?php if (isset($_GET['success'])) { ?>
      			<div class="alert alert-success" role="alert">
      			<?php echo htmlspecialchars($_GET['success']);?>
      			</div>
      			<?php } ?>
      			<div class="mb-3">
      			<label class="form-label">
      			Nome utente</label>
      			<input type="text" 
      			class="form-login"
      			name="username">
      			</div>
      
      			<div class="mb-3">
      			<label class="form-label">
      			Password</label>
      			<input type="password" 
      			class="form-login"
      			name="password">
      			</div>
      									  
      			 <button type="submit" 
      			 class="btn btn-outline-secondary">
      			 Accedi</button>
      			 <a class="btn btn-outline-secondary" href="signup.php" role="button">Registrati</a>
      			 <hr>
      			 <br>
      			 <a class="btn btn-outline-secondary" href="recupero.php" role="button">Password dimenticata?</a>
      			 </form>  
      ----------------------------------------------
      
      <?php  
      session_start();
      
      # check if username & password  submitted
      if(isset($_POST['username']) &&
         isset($_POST['password'])){
      
         # database connection file
         include '../db.conn.php';
         
         # get data from POST request and store them in var
         $password = $_POST['password'];
         $username = $_POST['username'];
         
         $data = "username=".$username;
         
         #simple form Validation
         if(empty($username)){
            # error message
            $em = "inserisci il nome utente";
      
            # redirect to 'index.php' and passing error message
            header("Location: ../../index.php?error=$em&$data");
         }else if(empty($password)){
            # error message
            $em = "inserisci la password";
      
            # redirect to 'index.php' and passing error message
            header("Location: ../../index.php?error=$em&$data");
         }else {
            $sql  = "SELECT * FROM 
                     users WHERE username=?";
            $stmt = $conn->prepare($sql);
            $stmt->execute([$username]);
      
            # if the username is exist
            if($stmt->rowCount() === 1){
              # fetching user data
              $user = $stmt->fetch();
      		
              # if both username's are strictly equal
              if ($user['username'] === $username) {
                 
                 # verifying the encrypted password
                if (password_verify($password, $user['password'])) {
      			  
      
                  # successfully logged in
                  # creating the SESSION
                  $_SESSION['username'] = $user['username'];
                  $_SESSION['name'] = $user['name'];
                  $_SESSION['user_id'] = $user['user_id'];
      
                  # redirect to 'home.php'
                  header("Location: ../../home.php");
      
                }else {
                  # error message
                  $em = "Nome utente o password errati";
      
                  # redirect to 'index.php' and passing error message
                  header("Location: ../../index.php?error=$em&$data");
                }
              }else {
                # error message
                $em = "Nome utente o password errati";
      
                # redirect to 'index.php' and passing error message
                header("Location: ../../index.php?error=$em&$data");
              }
            }
         }
      }else {
        header("Location: ../../index.php");
        exit;
      }
      
      
      
      
      
      postato in Coding
      I
      imperor
    • RE: sessione utente elimina chat

      @oceweb ciao e buona domenica 🙂 sono riuscito a eliminare la chat ora sia l'utente A e B possono eliminare la chat ma la conversazione la può eliminare solo chi invia o chi riceve non riesco a capire cosa manca posto i codici ```

      <?php 
      
      function getConversation($user_id, $conn){
          /**
            Getting all the conversations 
            for current (logged in) user
          **/
          $sql = "SELECT * FROM conversations
                  WHERE user_1=? OR user_2=?
                  ORDER BY conversation_id DESC";
      
          $stmt = $conn->prepare($sql);
          $stmt->execute([$user_id, $user_id]);
      
          if($stmt->rowCount() > 0){
              $conversations = $stmt->fetchAll();
      
              /**
                creating empty array to 
                store the user conversation
              **/
              $user_data = [];
              
              # looping through the conversations
              foreach($conversations as $conversation){
                  # if conversations user_1 row equal to user_id
                  if ($conversation['user_1'] == $user_id) {
                  	$sql2  = "SELECT *
                  	          FROM users WHERE user_id=?";
                  	$stmt2 = $conn->prepare($sql2);
                  	$stmt2->execute([$conversation['user_2']]);
                  }else {
                  	$sql2  = "SELECT *
                  	          FROM users WHERE user_id=?";
                  	$stmt2 = $conn->prepare($sql2);
                  	$stmt2->execute([$conversation['user_1']]);
                  }
      
                  $allConversations = $stmt2->fetchAll();
      
                  # pushing the data into the array 
                  array_push($user_data, $allConversations[0]);
              }
      
              return $user_data;
      
          }else {
          	$conversations = [];
          	return $conversations;
          }  
      
      }
      ---------------------------
       <ul id="chatList"
          		    class="list-group mvh-50 overflow-auto">
          			<?php if (!empty($conversations)) { ?>
          			    <?php 
      
          			    foreach ($conversations as $conversation){ ?>
      	    			<li class="list-group-item">
      	    				<a href="chat.php?user=<?=$conversation['username']?>"
      	    				   class="d-flex
      	    				          justify-content-between
      	    				          align-items-center p-2">
      	    					<div class="d-flex
      	    					            align-items-center">
      	    					    <img src="uploads/<?=$conversation['p_p']?>"
      	    					         class="w-10 rounded-circle">
      	    					    <h3 class="fs-xs m-2">
      	    					    	<?=$conversation['name']?><br>
                            <small>
                              <?php 
                                echo lastChat($_SESSION['user_id'], $conversation['user_id'], $conn);
                              ?>
                            </small>
      	    					    </h3>            	
      	    					</div>
      	    					<?php if (last_seen($conversation['last_seen']) == "Active") { ?>
      		    					<div title="online">
      		    						<div class="online"></div>
      		    					</div>
      	    					<?php } ?>
      	    				</a>
      						<a href="deleteconv.php?user_2=<?=$conversation['user_id']?>" class="btn btn-danger"><i class="fa fa-trash-o"></i> Elimina messaggi</a>
      	    			</li>
      
      
      postato in Coding
      I
      imperor
    • RE: sessione utente elimina chat

      @overclokk si concordo in effetti come ho già scritto la chat l'ho scaricata su YouTube fino al 2005 programmavo il mirc con il vincula lo usavo per proteggere le ex chat msn 😋 sinceramente era più facile scrivere il codice

      postato in Coding
      I
      imperor
    • RE: sessione utente elimina chat

      @oceweb ciao e buongiorno 🙂 non capisco perchè le conversazioni che sono nella home.php riesco a eliminarla solo con: user_1 oppure user_2 ma se provo a inserire conversation_id non funziona posto il codice dove stampa a video le conversazioni

      function getConversation($user_id, $conn){
          /**
            Getting all the conversations 
            for current (logged in) user
          **/
          $sql = "SELECT * FROM conversations
                  WHERE user_1=? OR user_2=?
                  ORDER BY conversation_id DESC";
      
          $stmt = $conn->prepare($sql);
          $stmt->execute([$user_id, $user_id]);
      
          if($stmt->rowCount() > 0){
              $conversations = $stmt->fetchAll();
      
              /**
                creating empty array to 
                store the user conversation
              **/
              $user_data = [];
              
              # looping through the conversations
              foreach($conversations as $conversation){
                  # if conversations user_1 row equal to user_id
                  if ($conversation['user_1'] == $user_id) {
                  	$sql2  = "SELECT *
                  	          FROM users WHERE user_id=?";
                  	$stmt2 = $conn->prepare($sql2);
                  	$stmt2->execute([$conversation['user_2']]);
                  }else {
                  	$sql2  = "SELECT *
                  	          FROM users WHERE user_id=?";
                  	$stmt2 = $conn->prepare($sql2);
                  	$stmt2->execute([$conversation['user_1']]);
                  }
      
                  $allConversations = $stmt2->fetchAll();
      
                  # pushing the data into the array 
                  array_push($user_data, $allConversations[0]);
              }
      
              return $user_data;
      
          }else {
          	$conversations = [];
          	return $conversations;
          }  
      
      }
      
      postato in Coding
      I
      imperor
    • RE: sessione utente elimina chat

      @oceweb ariciao 🙂 ho fatto come mi hai detto e funziona! 😋 grazie x l'aiuto

      postato in Coding
      I
      imperor
    • RE: sessione utente elimina chat

      @oceweb ciao sinceramente non ho provato come mi hai detto ti mostro il codice dove preleva i messaggi sia inviati e ricevuti e li mostra nel file chat.php

      <?php 
      
      function getChats($id_1, $id_2, $conn){
         
         $sql = "SELECT * FROM chats
                 WHERE (from_id=? AND to_id=?)
                 OR    (to_id=? AND from_id=?)
                 ORDER BY chat_id ASC";
          $stmt = $conn->prepare($sql);
          $stmt->execute([$id_1, $id_2, $id_1, $id_2]);
      
          if ($stmt->rowCount() > 0) {
          	$chats = $stmt->fetchAll();
          	return $chats;
          }else {
          	$chats = [];
          	return $chats;
          }
      
      }
      
      ?>
      
      
      postato in Coding
      I
      imperor
    • RE: sessione utente elimina chat

      la sessione è user_id

      postato in Coding
      I
      imperor
    • RE: sessione utente elimina chat

      @oceweb ciao questa è la struttura delle tabelle sia conversazione e chat

      
      -- Struttura della tabella `chats`
      --
      
      CREATE TABLE `chats` (
        `chat_id` int(11) NOT NULL,
        `from_id` int(11) NOT NULL,
        `to_id` int(11) NOT NULL,
        `message` text NOT NULL,
        `opened` tinyint(1) NOT NULL DEFAULT 0,
        `create_datetime` datetime NOT NULL DEFAULT current_timestamp()
      ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
      
      -- --------------------------------------------------------
      
      --
      -- Struttura della tabella `conversations`
      --
      
      CREATE TABLE `conversations` (
        `conversation_id` int(11) NOT NULL,
        `user_1` int(11) NOT NULL,
        `user_2` int(11) NOT NULL
      ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
      
      
      postato in Coding
      I
      imperor
    • RE: sessione utente elimina chat

      @overclokk ciao no non ho risolto riesco a eliminare chi invia ma no chi riceve ho riprovato ma elimina chi riceve ma no chi invia come posso fare per eliminare sia chi riceve e chi invia? ho scaricato la chat messaggio privato su YouTube in effetti in fase di registrazione non controlla se la mail è esistente il sito l'ho caricato sul mio dominio fcfclean.it/sito utente Francesco pass albachiara/12 è una pass di test sono riuscito anche a resettare la pass dimenticata non sono un programmatore ma autodidatta il sito è x l'amministratore di condominio dove i condomini si registrano e possono scaricare i doc inviati da l'amministratore e cambiare la foto profilo ho fatto anche la parte admin devo dire che non credo che il sito sia sicuro sto cercando un programmatore logico pagando x sistemare ciò

      postato in Coding
      I
      imperor
    • RE: sessione utente elimina chat

      risolto 🙂

      postato in Coding
      I
      imperor
    • sessione utente elimina chat
      salve sto tentando di eliminare una chat la sessione è username ma non ci riesco dove sbaglio?
      
      <a href="delchat.php<?=$chat['message']?><?=$chat['to_id']?>" class="btn btn-danger"><i class="fa fa-trash-o"></i> Delete</a>		
      
      
      file delchat.php
      <?php
      
          include 'app/db.conn.php';
      	
      	
          $get_id = $_GET['to_id'];
      	$conn->query("delete from chats where to_id = '$get_id'");
      	header('location:home.php');
      ?>
      
      postato in Coding
      I
      imperor
    • elimina chat utente loggato

      buongiorno sto tentando di eliminare due tabelle ho provato cosi ma non va 😞 :

      CREATE TABLE `chats` (
        `chat_id` int(11) NOT NULL,
        `from_id` int(11) NOT NULL,
        `to_id` int(11) NOT NULL,
        `message` text NOT NULL,
        `opened` tinyint(1) NOT NULL DEFAULT 0,
        `created_at` datetime NOT NULL DEFAULT current_timestamp()
      ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
      
      -- --------------------------------------------------------
      
      --
      -- Table structure for table `conversations`
      --
      
      CREATE TABLE `conversations` (
        `conversation_id` int(11) NOT NULL,
        `user_1` int(11) NOT NULL,
        `user_2` int(11) NOT NULL
      ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
      -----------------------------------------------------------
      <?php  
      
      session_start();
      
      # check if the user is logged in
      if(isset($_POST['del'])){
      	
      	# database connection file
      	include 'app/db.conn.php';
      
      	# get the logged in user's username from SESSION
      	$user_id = $_SESSION['user_id'];
      	$chat_id = $_POST['chat_id'];
      	$conversation_id = $_POST['conversation_id'];
      
      $sql = "DELETE chats,conversations
        FROM chat_id AS chats
        LEFT JOIN conversation_id AS conversations ON chat_id.from_id = conversation_id.conversation_id
        WHERE chat_id.from_id = 2;'");
      $stmt= $conn->prepare($sql);
      $stmt->execute([$chat_id, $conversation_id]);
      
      
      	header("Location: home.php");
      	exit;
      }
      
      ?>
      <form action="delchat.php" method="post" enctype="multipart/form-data">
      <input type="hidden" value="<?=$user['username']?>">  
      <input type="submit" name="del" value="Elimina chat">
      </form>
      
      
      
      
      postato in Coding
      I
      imperor