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

    sito con registrazione e login

    Ciao a tutti mi serve una mano ecco cosa devo fare:

    form di ingresso dell’utente con login e password per utenti gia’ registrati e dati di
    registrazione per nuovi utenti; i dati di registrazione devono almeno comprendere:
    dati anagrafici, e-mail e selezione di preferenze di stile per le pagine:
    a. colori di sfondo, dimensioni, tipo o colore dei caratteri,
    b. posizionamento di informazioni, (ossia per es. menu’ a sinistra, o a destra)

    questo è il codice che ho fatto per le registrazione:

    <!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>Inizio registrazione</title>
    <script language="JavaScript" type="text/JavaScript">


    function check_form(f)
    {
    var msg="ATTENZIONE!!";
    var error=false;
    var email_pattern=/^\w+@([\w.])+\w+$/;

    if (f.nome.value=="") {msg=msg+"\n Il campo Nome è obbligatorio."; error=true;}
    if (f.cognome.value=="") {msg=msg+"\n Il campo Cognome obbligatorio."; error=true;}
    if (f.username.value=="") {msg=msg+"\n Il campo Username è obbligatorio."; error=true;}
    if (f.password.value=="") {msg=msg+"\n Il campo password è obbligatorio."; error=true;}

    if (f.password2.value=="") {msg=msg+"\n Il campo conferma password è obbligatorio."; error=true;}

    else if (f.password.value != f.password2.value)
    {
    error=true;
    msg=msg+"\n Devi immettere la stessa password"
    }


    if (f.luogo_nascita.value=="") {msg=msg+"\n Il campo luogo è obbligatorio."; error=true;}
    if (f.giorno.value=="" || f.mese.value=="" || f.anno.value=="") {msg=msg+"\n Il campo data è obbligatorio."; error=true;}
    else if (f.giorno.value < 1 || f.giorno.value > 31 || f.mese.value < 1 || f.mese.value > 12 || f.anno.value < 1900 || f.anno.value > 2011)
    {
    error=true;
    msg=msg+"\n La data è inesistente."
    }
    else if (f.anno.value.length != 4 || f.giorno.value.length != 2 || f.mese.value.length != 2)
    {
    error=true;
    msg=msg+"\n Immetti una data in forma gg/mm/aaaa."
    }
    if(!giorno_pattern.test(f.giorno.value) || !mese_pattern.test(f.mese.value) || !anno_pattern.test(f.anno.value)) {msg=msg+"\n Il campo data deve contenere dei numeri."; error=true;}


    var s_sel=false;
    i=0;
    while(i<f.sex.length && !s_sel)
    {
    if (f.sex[i].checked) s_sel=true;
    i++;
    }
    if (!s_sel) {msg=msg+"\n Selezionare il campo sesso (M o F)."; error=true;}

    var s_sel=false;
    i=0;
    while(i<f.sfon.length && !s_sel)
    {
    if (f.sfon[i].checked) s_sel=true;
    i++;
    }
    if (!s_sel) {msg=msg+"\n Selezionare il campo sfondo."; error=true;}

    var s_sel=false;
    i=0;
    while(i<f.dim.length && !s_sel)
    {
    if (f.dim[i].checked) s_sel=true;
    i++;
    }
    if (!s_sel) {msg=msg+"\n Selezionare la dimensione dei caratteri."; error=true;}

    var s_sel=false;
    i=0;
    while(i<f.col.length && !s_sel)
    {
    if (f.col[i].checked) s_sel=true;
    i++;
    }
    if (!s_sel) {msg=msg+"\n Selezionare il colore dei caratteri."; error=true;}

    var s_sel=false;
    i=0;
    while(i<f.tipo.length && !s_sel)
    {
    if (f.tipo[i].checked) s_sel=true;
    i++;
    }
    if (!s_sel) {msg=msg+"\n Selezionare lo stile dei caratteri."; error=true;}





    if(!email_pattern.test(f.mail.value)) {msg=msg+"\n Il campo e-mail non è corretto."; error=true;}

    if (error) {alert(msg); return false;}




    }





    function answer(f)
    {
    var nome=f.nome.value;
    var cognome=f.cognome.value;
    var username=f.username.value;
    var password=f.password.value;
    var password2=f.password2.value;
    var giorno=f.giorno.value;
    var mese=f.mese.value;
    var anno=f.anno.value;
    var luogo_nascita=f.luogo_nascita.value;
    var sesso=new Array();

    for(var i=0; i<f.sex.length; i++) {sesso[i]=new Object();
    sesso[i].checked=f.sex[i].checked;sesso[i].value=f.sex[i].value;}
    var sfondo=new Array();

    var sfondo=new Array();
    for(var i=0; i<f.sfon.length; i++) {sfondo[i]=new Object();
    sfondo[i].checked=f.sfon[i].checked;sfondo[i].value=f.sfon[i].value;}

    var dimensione=new Array();
    for(var i=0; i<f.dim.length; i++) {dimensione[i]=new Object();
    dimensione[i].checked=f.dim[i].checked;dimensione[i].value=f.dim[i].value;}

    var colore=new Array();
    for(var i=0; i<f.col.length; i++) {colore[i]=new Object();
    colore[i].checked=f.col[i].checked;colore[i].value=f.col[i].value;}

    var stile=new Array();
    for(var i=0; i<f.tipo.length; i++) {stile[i]=new Object();
    stile[i].checked=f.tipo[i].checked;stile[i].value=f.tipo[i].value;}

    var mail=f.mail.value;

    document.writeln("<html><head><title>Grazie!</title><head>");

    document.writeln("<body>");
    document.writeln("<h1>La tua registrazione è avvenuta con successo.</h1>");
    document.writeln("<h3>Conserva username e password per accedere al sito!</h3>");
    document.writeln("<h3> Ecco i dati da te inseriti: </h3>");
    document.write("

    Nome: "+nome+"</p>");
    document.writeln("

    Cognome: "+cognome+"</p>");
    document.writeln("

    Username: "+username+"</p>");
    document.writeln("

    Password: "+password+"</p>");
    document.writeln("

    Nato/a a: "+luogo_nascita+"</p>");
    document.writeln("

    Il: "+giorno+"/"+mese+"/"+anno+"</p>");
    document.write("

    Sesso ");
    if(sesso[0].checked) document.writeln("maschile </p>"); else document.writeln("femminile </p>");
    document.writeln("

    Email: "+mail+"</p>");
    document.writeln("</body></html>");

    }
    </script>
    </head>

    <body>
    Per accedere al sito devi registrarti!! </p>


    Immetti i seguenti dati: </p>

    <form name="myform" action="java-script:answer(document.myform)" method="post" onSubmit="return(check_form(this))" onReset="return(confirm('Sei sicuro di voler cancellare i dati?'))">



    <label> Nome </label>
    <input name="nome" type="text" id="nome" size="20" maxlength="20" />
    <label> Cognome </label>
    <input name="cognome" type="text" id="cognome" size="20" maxlength="20" />
    </p>



    <labe> Username </label>
    <input name="username" type="text" id="username" size="20" maxlength="20" />
    </p>



    <label> Password </label>
    <input name="password" type="text" id="password" size="20" maxlength="15" />
    <label> Reimmetti_Password </label>
    <input name="password2" type="text" id="password2" size="20" maxlength="15" />
    </p>



    <label> Data di nascita </label>
    <input name="giorno" type="text" id="giorno" size="2" maxlength="2" />
    /
    <input name="mese" type="text" id="mese" size="2" maxlength="2" />
    /
    <input name="anno" type="text" id="anno" size="4" maxlength="4" />
    </p>



    <label> Luogo di nascita </label>
    <input name="luogo_nascita" type="text" id="luogo_nascita" size="30" maxlength="50" />
    </p>



    Sesso: <label>M</label>
    <input name="sex" type="radio" value="m" />
    <label>F</label>
    <input name="sex" type="radio" value="f" />
    </p>




    <label> E-mail: </label>
    <input name="mail" type="text" id="mail" />



    Ora scegli le tue preferenze di stile per la pagina: </p>







    Sfondo: <label>Blu</label>
    <input name="sfon" type="radio" value="Blu" />
    <label>Giallo</label>
    <input name="sfon" type="radio" value="Giallo" />
    <label>Arancione</label>
    <input name="sfon" type="radio" value="Arancione" />
    <label>Verde</label>
    <input name="sfon" type="radio" value="Verde" />
    </p>






    Dimensione: <label>Piccola</label>
    <input name="dim" type="radio" value="Piccola" />
    <label>Media</label>
    <input name="dim" type="radio" value="Media" />
    <label>Grande</label>
    <input name="dim" type="radio" value="Grande" />

    </p>






    Colore caratteri: <label>Rossi</label>
    <input name="col" type="radio" value="Rossi" />
    <label>Neri</label>
    <input name="col" type="radio" value="Neri" />
    <label>Blu</label>
    <input name="col" type="radio" value="Blu" />

    </p>






    Stile del testo: <label>Times New Roman</label>
    <input name="tipo" type="radio" value="Times New Roman" />
    <label>Georgia</label>
    <input name="tipo" type="radio" value="Georgia" />
    <label>Arial</label>
    <input name="tipo" type="radio" value="Arial" />

    </p>





    <input type="submit" name="Submit" value="Invia" />
    <input name="Reset" type="reset" value="Ripristina" />
    </p>


    </form>

    </body>

    </html>


    e questa è la pagina di login:


    <!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>Benvenuto!</title>
    <script language="JavaScript" type="text/JavaScript">
    function controllo(f)
    {
    var msg=""
    var error=false;

    if (f.username.value=="" || f.password.value=="") {msg=msg+"Non hai inserito username e password, se non sei registrato, registrati per entrare nel sito."; error=true;}

    if (error) {alert(msg); return false;}

    if(document.cookie)
    {
    var myCookie = unescape(document.cookie);
    var cookieTokens = myCookie.split ( "=" );
    username = cookieTokens [1];
    }
    if (f.username.value) {msg=msg+"No"; error=true;}

    if (error) {alert(msg); return false;}
    }
    function risposta(f)
    {
    var username=f.username.value;
    var password=f.password.value;

    document.writeln("<html> <head> <title> Benvenuto nel sito! </title> <head>");

    document.writeln("<body>");
    document.writeln("

    Benvenuto "+username+" </p>");
    document.writeln("

    Clicca <a href=file:///C:/Users/Elisa/Desktop/sito/presentazione.html>qui</a href> per visualizzare uno slide di immagini!</p>");
    document.writeln("

    Clicca <a href=file:///C:/Users/Elisa/Desktop/sito/puzzle.htm>qui</a href>qui per visualizzare il puzzle dell'8!</p>");
    document.writeln("

    Clicca <a href=file:///C:/Users/Elisa/Desktop/sito/memory.html>qui</a href> per visualizzare il gioco delle carte!</p>");
    document.writeln("

    Clicca <a href=file:///C:/Users/Elisa/Desktop/sito/calcolatrice.htm>qui</a href> per visualizzare una calcolatrice!</p>");
    document.writeln("</body></html>");
    }
    </script>
    </head>

    <body>
    <p style= "font-size: 16pt; color: #ff00ff" >
    Immetti username e password. </p>
    <map id = "images"> </map>

    <img src = "images.jpg" width = "200" height = "144"
    alt = disney" usemap = '#images" />

    <form name="myform" action="java-script:risposta(document.myform)" method="post" onsubmit="return(controllo(this))">



    <label> Username </label>
    <input name="username" type="text" id="username" size="20" maxlength="20" />
    </p>



    <label> Password </label>

    <input name="password" type="password" id="password" size="20" maxlength="15" />
    </p>



    <input type="submit" name="Submit" value="Invia" />
    </p>
    </form>


    Se non sei registrato clicca <a href=file:///C:/Users/Elisa/Desktop/sito/registrazione_copia.html>qui</a href> </p>

    </body>

    </html>


    E’ comunque richiesto l’impiego di CSS per la strutturazione delle pagine
    Il mio problema è salvare nel cookie utente e password e i fogli di stile e farglieli applicare.. che devo fare?? qualcuno mi aiuti!!! GRAZIE INFINITE

  2. #2
    Moderatore di JavaScript L'avatar di br1
    Registrato dal
    Jul 1999
    Messaggi
    19,998
    Leggi il regolamento... alla voce "crossposting"
    Il guaio per i poveri computers e' che sono gli uomini a comandarli.

    Attenzione ai titoli delle discussioni: (ri)leggete il regolamento
    Consultate la discussione in rilievo: script / discussioni utili
    Usate la funzione di Ricerca del Forum

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.