ho un guesbook (luke guestbook) ma devo impedire agli utenti non loggati di inserire nel titolo la parola "capo"
avevo pensato ad una
if (Session("amministratore") = "OK" then procedi normalmente else
if (nome == "" || nome == "capo" || nome == "undefined" || nome.charAt(0) == " ") redirect su pagina di errore
ma vorrei un consiglio
grazie in anticipo
il codice è:
codice:// RECUPERO I DATI DAL MODULO PER EFFETTUARE LA REGISTRAZIONE var nome = new String(Request.Form("nome")); var email = new String(Request.Form("email")); var homepage = new String(Request.Form("homepage")); var titolo = new String(Request.Form("titolo")); var messaggio = new String(Request.Form("messaggio")); // ESPRESSIONE REGOLARE PER LA VERIFICA DELL'INDIRIZZO EMAIL var verifica = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-]{2,})+\.)+([a-zA-Z0-9]{2,})+$/; // CREO LA DATA var oggi = new Date(); var data = oggi.getDate() + "/" + (oggi.getMonth() + 1) + "/" + oggi.getFullYear(); var ora = oggi.getHours() + ":" + oggi.getMinutes(); // VALIDAZIONE DEI DATI INSERITI DALL'UTENTE var errore = "guestbook.asp?azione=errore&codice="; if (nome == "" || nome == "undefined" || nome.charAt(0) == " ")) { Response.Redirect(errore + "1"); } else if (!verifica.test(email)) { Response.Redirect(errore + "2"); } else if (titolo == "" || titolo == "undefined" || titolo.charAt(0) == " ") { Response.Redirect(errore + "3"); } else if (messaggio == "" || messaggio == "undefined" || messaggio.charAt(0) == " ") { Response.Redirect(errore + "4"); } else { var r_messaggio = messaggio.replace(/</g, "<"); var rr_messaggio = r_messaggio.replace(/>/g, ">"); var rrr_messaggio = rr_messaggio.replace(/&/g, "&"); var rrrr_messaggio = rrr_messaggio.replace(/\n/g, " "); // CASO IN CUI TUTTE LE CONDIZIONI SONO STATE SODDISFATTE // QUINDI PROCEDO CON LA REGISTRAZIONE DEL MESSAGGIO var recordset = new ActiveXObject("ADODB.Recordset"); recordset.Open("messaggi",connessione,3,3); recordset.AddNew(); recordset("nome") = nome; recordset("email") = email; recordset("homepage") = homepage; recordset("titolo") = titolo; recordset("messaggio") = rrrr_messaggio; recordset("data") = data; recordset("ora") = ora; recordset.Update(); recordset.Close(); Response.Redirect("guestbook.asp"); } } else if (azione == "errore") { // LOGIN PER L'AMMINISTRATORE var password = new String(Request.Form("password")); if (password == admin_password) { Session("amministratore") = "OK"; } Response.Redirect("guestbook.asp"); } else if (azione == "Logout") { // LOGOUT PER L'AMMINISTRATORE Session.Abandon(); Response.Redirect("guestbook.asp"); } else if (azione == "Cancella") {

Rispondi quotando
