Visualizzazione dei risultati da 1 a 7 su 7

Discussione: Dati validati

  1. #1

    Dati validati

    Ciao a tutti, ecco il problema.

    Devo fare in modo che i dati che inserisco in un db mysql tramite un modulo vengano nel caso di caratteri speciali quali virgolette accenti e cos'altro superare la validazione del consorzio W3, una volta che vengono visualizzati nel sito.

    come faccio?
    Se leggo dimentico,
    se scrivo ricordo,
    se faccio imparo.
    Antonio Volino | Tra Virgolette

  2. #2
    Utente di HTML.it
    Registrato dal
    Aug 2002
    Messaggi
    8,013
    <´¯)(¯`¤._)(¯`»ANDREA«´¯)(_.¤´¯)(¯`>
    "The answer to your question is: welcome to tomorrow"

  3. #3

    grazie

    grazie Andrea1979

    mi sto documentando, spero di risolvere.

    codice:
    <?php require_once('../Connections/connessione.php'); ?>
    <?php
    function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
    {
      $theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue;
    
      switch ($theType) {
        case "text":
          $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
          break;    
        case "long":
        case "int":
          $theValue = ($theValue != "") ? intval($theValue) : "NULL";
          break;
        case "double":
          $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
          break;
        case "date":
          $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
          break;
        case "defined":
          $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
          break;
      }
      return $theValue;
    }
    
    $editFormAction = $_SERVER['PHP_SELF'];
    if (isset($_SERVER['QUERY_STRING'])) {
      $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
    }
    
    if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "insNews")) {
      $insertSQL = sprintf("INSERT INTO news_articles (subject, message, `date`) VALUES (%s, %s, %s)",
                           GetSQLValueString($_POST['subject'], "text"),
                           GetSQLValueString($_POST['message'], "text"),
                           GetSQLValueString($_POST['date'], "text"));
    
      mysql_select_db($database_unifarm, $unifarm);
      $Result1 = mysql_query($insertSQL, $unifarm) or die(mysql_error());
    
      $insertGoTo = "list_News.php";
      if (isset($_SERVER['QUERY_STRING'])) {
        $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
        $insertGoTo .= $_SERVER['QUERY_STRING'];
      }
      header(sprintf("Location: %s", $insertGoTo));
    }
     
    virtual('../Connections/unifarm.php'); ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
    <title>Inserisci nuova news</title>
    <link href="stileadmin.css" rel="stylesheet" type="text/css" />
    </head>
    
    <body>
    <div align="center">[img]/test/img_head/03.jpg[/img] </div>
    <div id="lista">
    <h1>Inserisci nuova news:</h1>
    <form action="<?php echo $editFormAction; ?>" id="insNews" name="insNews" method="POST">
    
    <table border="0" cellpadding="2" cellspacing="2">
      <tr>
        <td width="8%" valign="top">
    
    Data:</p></td>
        <td width="92%">
    
    
                <input name="date" type="text" id="date" />
            gg/mm/aaaa</p></td>
      </tr>
      <tr>
        <td valign="top">
    
    Titolo:</p></td>
        <td><label>
          <input name="subject" type="text" id="subject" />
        </label></td>
      </tr>
      <tr>
        <td valign="top">
    
    Testo:</p></td>
        <td><label>
          <textarea name="message" cols="40" rows="15" id="message"></textarea>
        </label></td>
      </tr>
      <tr>
        <td></td>
        <td>
            <a href="javascript:history.back()" class="tasto"> Torna indietro
            
            </a>
          <input class="tasto" type="submit" name="Submit" value="Inserisci" />    </td>
      </tr>
    </table>
    
    
    
    
      </p>
    
    
    <a href="menu.php">
          </a>
      <input type="hidden" name="MM_insert" value="insNews">
    </p>
    </form></div>
    </body>
    </html>
    Se leggo dimentico,
    se scrivo ricordo,
    se faccio imparo.
    Antonio Volino | Tra Virgolette

  4. #4

    non so che devo fare

    uffi
    Se leggo dimentico,
    se scrivo ricordo,
    se faccio imparo.
    Antonio Volino | Tra Virgolette

  5. #5
    Utente di HTML.it
    Registrato dal
    Aug 2002
    Messaggi
    8,013
    ma le hai scritte tu quelle funzioni? Quegli "MM_" sembrano di DW.
    Ad ogni modo, dove vuoi che vengano stampate a video le cose salvate in database, fai

    codice:
    echo(htmlentities($dati_dalla_query));

    Nel pezzo di codice che hai postato si vedono solo funzioni per l'inserimento in DB: ora, potresti anche convertire prima dell'inserimento in DB, ma fossi in te non lo farei (potresti aver necessità dei dati in un formato testuale non web-compliant)
    <´¯)(¯`¤._)(¯`»ANDREA«´¯)(_.¤´¯)(¯`>
    "The answer to your question is: welcome to tomorrow"

  6. #6
    codice:
    <h1>News</h1>
    	<ul>
    		  <?php do { ?>
    		[*]<a href="readnews.php?id=<?php echo $row_news['id']; ?>"><?php echo $row_news['date']; ?>
    
     <?php echo htmlentities ( $row_news['subject']); ?></a>
     
    
    		    <?php } while ($row_news = mysql_fetch_assoc($news)); ?>[/list]
    ho inserito questa funziona qui, ma quando visualizzo l'html mi compaiono sempre le ""
    Se leggo dimentico,
    se scrivo ricordo,
    se faccio imparo.
    Antonio Volino | Tra Virgolette

  7. #7

    perchè!!!!!!!

    ho scritto anche come hai scritto tu, anche inserendo

    <?php echo (htmlentities ( $row_news['subject'], ENT_QUOTES)); ?>

    ma nulla
    Se leggo dimentico,
    se scrivo ricordo,
    se faccio imparo.
    Antonio Volino | Tra Virgolette

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.