Visualizzazione dei risultati da 1 a 3 su 3
  1. #1

    Scusate Problema dati doppi

    Ho questo codice che funziona perfettamente per quando riguarda l'inserimento ma non mi controlla se vengono inseriti dati doppi nel database, nonostante abbia inserito la funzioni di controllo suggeritemi in qusto forum. Potrebbe qualcuno gentilmente dirmi dove stò sbagliando visto che sono alle primissime armi?
    Ecco il codice:

    <?php require_once('Connections/server.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']);
    }
    mysql_select_db($database_server, $server);
    $controllo = "SELECT user FROM prova WHERE user = '".$_POST['user']."'";
    $verifica = mysql_query($controllo);
    if ($verifica) {
    echo " query ok";
    } else {
    echo " query fallita - " . mysql_error();
    }
    $sessione = mysql_num_rows($verifica);
    if ($sessione == 12) {
    echo " esiste già l'utente";
    }
    else
    {
    if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1"))
    {
    $insertSQL = sprintf("INSERT INTO prova (`user`, nome) VALUES (%s, %s)",
    GetSQLValueString($_POST['user'], "text"),
    GetSQLValueString($_POST['nome'], "text"));
    mysql_select_db($database_server, $server);
    $Result1 = mysql_query($insertSQL, $server) or die("Devi Compilare tutti i campi");
    }
    }

    ?>

  2. #2
    if ($sessione == 12) {
    echo " esiste già l'utente";

    Con questo controllo ti dice che esiste solo quando ne trovera' 12.

    prova con:

    if($sessione > 0 )

    Il silenzio è spesso la cosa migliore. Pensa ... è gratis.

  3. #3

    ho già provato

    quel controllo sullo script era settato a =1 forse c'è stato un errore quando l'ho ricopiato per postare un messaggio, ma non funzionava uguale, o meglio i dati venivano inseriti ugualmente anche se erano doppi.

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.