Visualizzazione dei risultati da 1 a 4 su 4

Discussione: Ridondanza dei dati

  1. #1

    Ridondanza dei dati

    Salve ragazzi ho questo problema:

    Ho creato un form di iscrizione utenti ed ora vorrei effettuare un controllo affinchè uno stesso utente posse iscriversi una sola volta,
    quindi un controllo sull'esistenza ne database dei dati, come posso fare

  2. #2
    hai due strade : o rendi unico i campi sul database in modo che possano contenere solo una volta lo stesso dato...oppure controlli prima di inserire i dati che nn ci sia già qualche utente con stessi dati ...es così :

    $controllo = "SELECT * FROM utenti WHERE nome_utente = $_POST['dato_inserito dall'utente'] ";
    $verifica = mysql_query ($controllo) or mysql_error();
    $sessione = mysql_num_rows ($verifica);
    if ($sessione == 1) {
    echo " esiste già l'utente"
    }else{
    esegui la registrazione



  3. #3

    errore

    Ho provato a fare come dici ma ho il seguente errore:

    syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING

    Per meglio far capire il tutto posto il mio 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']);
    }
    $controllo = "SELECT * FROM prova WHERE user = $_POST['user'] ";
    $verifica = mysql_query ($controllo) or mysql_error();
    $sessione = mysql_num_rows ($verifica);
    if ($sessione == 1) {
    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(mysql_error());
    }
    ?>

  4. #4
    echo " esiste già l'utente"; >> mancava il punto e virgola
    }else{

    e aggiungi alla fine un'altra } che mi sembra manchi

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.