Visualizzazione dei risultati da 1 a 4 su 4

Discussione: Stripslashes

  1. #1
    Utente di HTML.it
    Registrato dal
    Mar 2005
    Messaggi
    81

    Stripslashes

    Salve,
    scusate la domanda sicuramente banale ma sono molto a digiuno sul PHP.

    In questo codice utilizzato per un form mail, dove devo aggiungere lo "stripslashes" per far si che nella mail ricevuta non compaia l'apostrofo con lo slash subito dopo (es. L'\accento)?

    Codice PHP:
      <?php
              
    if(isset($_POST['submit'])) {
              
    error_reporting(E_NOTICE);
              function 
    valid_email($str)
              {
              return ( ! 
    preg_match("/^([a-z0-9\+_\-]+)(\.[a-z0-9\+_\-]+)*@([a-z0-9\-]+\.)+[a-z]{2,6}$/ix"$str)) ? FALSE TRUE;
                 }


              if(
    $_POST['name']!='' && $_POST['email']!='' && valid_email($_POST['email'])==TRUE && strlen($_POST['comment'])>1)
              {
                  
    $to preg_replace("([\r\n])"""hexstr($_POST['receiver']));
                  
    $from preg_replace("([\r\n])"""$_POST['email']);
                  
    $subject "Email ricevuta da: ".$_POST['name'];
                  
    $message .= "Oggetto: ".$_POST['oggetto']."\r\n";
    $message .= "Messaggio: ".$_POST['comment'];


                  
                  
    $match "/(bcc:|cc:|content\-type:)/i";
                    if (
    preg_match($match$to) ||
                        
    preg_match($match$from) ||
                        
    preg_match($match$message)) {
                      die(
    "Header injection detected.");
                    }
            
    $headers "From: ".$from."\r\n";
            
    $headers .= "Reply-to: ".$from."\r\n";
            
                 
            if(
    mail($to$subject$message$headers))
                  {
                      echo 
    1//SUCCESS
                  
    }
                  else {
                      echo 
    2//FAILURE - server failure
                  
    }
              }
              else {
                 echo 
    3//FAILURE - not valid email

              
    }
              }else{
                 die(
    "Direct access not allowed!");
               }
               
                function 
    hexstr($hexstr) {
                      
    $hexstr str_replace(' '''$hexstr);
                      
    $hexstr str_replace('\x'''$hexstr);
                      
    $retstr pack('H*'$hexstr);
                      return 
    $retstr;
                    }

          
    ?>
    Oppure se c'è un altro modo, ho provato aggiungendo qualche funzione trovata in rete ma niente da fare..

    Grazie
    Nico

  2. #2
    Utente di HTML.it
    Registrato dal
    Apr 2004
    Messaggi
    3,709
    a occhio e croce potrebbe essere:

    Codice PHP:
    ...
    $message .= "Oggetto: ".stripslashes($_POST['oggetto'])."\r\n"
    $message .= "Messaggio: ".stripslashes($_POST['comment']); 
    ... 
    ...cmq dove usi le variabili $_POST che poi "passi" alla mail

  3. #3
    Utente di HTML.it
    Registrato dal
    Mar 2005
    Messaggi
    81
    Originariamente inviato da eiyen
    a occhio e croce potrebbe essere:

    Codice PHP:
    ...
    $message .= "Oggetto: ".stripslashes($_POST['oggetto'])."\r\n"
    $message .= "Messaggio: ".stripslashes($_POST['comment']); 
    ... 
    ...cmq dove usi le variabili $_POST che poi "passi" alla mail
    Cacchio!! L'avevo provato anche io ma ovviamente devo aver cannato qualcosa perchè non funzionava!

    Grazie mille, ora si vede tutto correttamente.

    Nico

  4. #4
    Utente di HTML.it
    Registrato dal
    Apr 2004
    Messaggi
    3,709
    Bene! Ciao...

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.