Visualizzazione dei risultati da 1 a 2 su 2
  1. #1
    Utente di HTML.it
    Registrato dal
    Sep 2015
    Messaggi
    4

    problema creazione nuovo utente in un database

    Buongiorno a tutti! Io ho un problema, devo creare un sito che effettui il login e la creazione di nuovi utenti che poi registrerà in un database. Se il nome utente è già presente nel database devo dire che il nome utente è già in uso, altrimenti aggiungerlo al database. Il database è payments.mdb e l'ho salvato nella cartella nella quale sono presenti le pagine del sito.
    Io ho scritto il codice seguente, ma mi da errore quando lo carico.. sono disperata, dove sbaglio? potete aiutarmi?
    Grazie mille!


    <!DOCTYPE HTML PUBLIC"-//W3C//DTD HTML 4.01//EN""http://www.w3.org/TR/html4/strict.dtd">
    <%@language="JScript"%>
    <!--#include file="adojavas.inc"-->

    <html>
    <head>

    <%
    nick = Replace(Request.QueryString("nick"), "'", "''");

    IF nick <> "" then
    var con;
    var conString;
    con = Server.CreateObject("ADODB.Connection");
    conString = "Provider=Microsoft.Jet.OLEDB.4.0; "+"Data Source="+Server.MapPath("payments.mdb");
    con.Open(conString);
    %>
    <title>Registrazione</title>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">

    </head>
    <body>

    <%

    var rst;
    var sSQLString;
    rst = Server.CreateObject("ADODB.Recordset");
    sSQLString = "SELECT * from users where nick = '" & nick &"'";
    rst.Open(sSQLString, con, adOpenStatic, adLockOptimistic);

    IF (!rst.EOF) Then

    usato = True
    Else

    usato = False
    End IF

    rst.Close();
    rst = Nothing;

    IF usato = True then
    %>

    <hr>
    <p align="center"><b><font face="Verdana" size="2">Username inserito già in uso!</font></b></p>
    <hr>

    <%
    Else

    rst = Server.CreateObject("ADODB.Recordset");
    sSQLString = "SELECT * from users Order By user_id Desc";
    rst.Open(sSQLString, con, adOpenStatic, adLockOptimistic);
    rst.Addnew;

    rst("nick") = nick;

    rst.Update;
    rst.Close();
    con.Close();
    rst = null;
    con = null:

    %>
    </body>
    </html>

  2. #2
    Moderatore di ASP e MS Server L'avatar di Roby_72
    Registrato dal
    Aug 2001
    Messaggi
    19,563
    Importante sarebbe capire che tipo di errore ti appare...
    Lo stai provando in locale o sul server? In quuest'ultimo caso, a meno di interventi ad hoc, difficile tu abbia i permessi di scrittura a livello di root (dove hai messo il database)...

    Roby

Tag per questa discussione

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 © 2024 vBulletin Solutions, Inc. All rights reserved.