Schermata login su pagina web
- PetrizzelliGraphics
- Entusiasta Emergente

- Messaggi: 2273
- Iscrizione: giovedì 2 novembre 2006, 15:34
- Località: Verona
- Contatti:
Schermata login su pagina web
- PetrizzelliGraphics
- Entusiasta Emergente

- Messaggi: 2273
- Iscrizione: giovedì 2 novembre 2006, 15:34
- Località: Verona
- Contatti:
Re: Schermata login su pagina web
E questa è la cosa più semplice.
Se invece vuoi qualcosa di piu' sicuro ti devi affidare ad uno script lato server. Nel tuo server hai la possibilità di utilizzare qualche linguaggio? php ad esempio? i tuoi dati fissi di riferimento li potresti mettere o in un db, tipo sqlite a cui accedi tramite path assoluto senza configurare alcun servizio, oppure in un documento xml o semplice file di testo in cui imposti i tuoi valori fissi di riferimento.
- MiguelX
- Scoppiettante Seguace

- Messaggi: 315
- Iscrizione: giovedì 17 maggio 2007, 20:03
- Località: Trapani
Re: Schermata login su pagina web
Re: Schermata login su pagina web
miguelx ha scritto: Non è più semplice lasciar fare ad apache e .htpasswd ?
e perche' no? si, certo.
- PetrizzelliGraphics
- Entusiasta Emergente

- Messaggi: 2273
- Iscrizione: giovedì 2 novembre 2006, 15:34
- Località: Verona
- Contatti:
Re: Schermata login su pagina web
http://www.nothing2hide.net/unixlinux/setup-di-apache2-mysql-e-php5-su-linux-ubuntu/che velocemente spiega come effettuare il setup di mysql con apache...è fin qua nessun problema...la guidetta è fatta bene...
Dopodichè passiamo alla creazione del login...guida molto breve ma non capisco perchè non mi funzioni!
http://www.informaticafriuli.com/programmazione-friuli-informatica/php-friuli/php-tutorial-come-creare-un-semplice-sistema-di-login-20070403.html
io ho creato i file descritti tali e quali come detto in guida...cioè senza mettere la intestazione HTML e cose varie...praticamente ho fatto un copia e incolla da lì e ho messo i tre file nella cartella del server apache "/var/www/" se accedo dal browser vedo i file...clicco su "main_login.php" e mi esce la schermatina per inserire user e password se do invio non succede niente.
Il database ovviamente è già creato!
- PetrizzelliGraphics
- Entusiasta Emergente

- Messaggi: 2273
- Iscrizione: giovedì 2 novembre 2006, 15:34
- Località: Verona
- Contatti:
- totò
- Gruppo Promozione

- Messaggi: 4363
- Iscrizione: giovedì 30 marzo 2006, 16:26
- Desktop: Ubuntu Mate
- Distribuzione: Ubuntu 18.04.1 LTS i686
- Sesso: Maschile
- Località: Scalea (CS)
- Contatti:
Re: Schermata login su pagina web
Abbi un pò di pazienza (yes)swimmerino88 ha scritto: Aiuto per favore!
io non ti so aiutare
ciao
- PetrizzelliGraphics
- Entusiasta Emergente

- Messaggi: 2273
- Iscrizione: giovedì 2 novembre 2006, 15:34
- Località: Verona
- Contatti:
Re: Schermata login su pagina web
ok badrone rimarrò in attesatotò ha scritto:Abbi un pò di pazienza (yes)swimmerino88 ha scritto: Aiuto per favore!
io non ti so aiutare
ciao![]()
Re: Schermata login su pagina web
e come ultima riga
Secondo me non fa nulla perche' non viene detto al bottone di submit cosa fare.
Anche se potrebbe darti qualche problema con la sessione, pero' dovrebbe funzionare.
ciao
- PetrizzelliGraphics
- Entusiasta Emergente

- Messaggi: 2273
- Iscrizione: giovedì 2 novembre 2006, 15:34
- Località: Verona
- Contatti:
Re: Schermata login su pagina web
grazie mille dell'aiuto comunque non funziona!prampa ha scritto:
prova ad inserire come prima riga nel file main_login.php
e come ultima riga
Secondo me non fa nulla perche' non viene detto al bottone di submit cosa fare.
Anche se potrebbe darti qualche problema con la sessione, pero' dovrebbe funzionare.
ciao
allora vi posto tutti i miei files con relativi nomi:
main_login.php
Codice: Seleziona tutto
<!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>Documento senza titolo</title>
</head>
<body>
<form action="checklogin.php" method="post">
<table align="center" bgcolor="#cccccc" border="0" cellpadding="0" cellspacing="1" width="300">
<tr>
<td>
<table bgcolor="#ffffff" border="0" cellpadding="3" cellspacing="1" width="100%">
<tr>
<td colspan="3"><strong>Member Login </strong></td>
</tr>
<tr>
<td width="78">Username</td>
<td width="6">:</td>
<td width="294"><input name="myusername" id="myusername" type="text" /></td>
</tr>
<tr>
<td>Password</td>
<td>:</td>
<td><input name="mypassword" id="mypassword" type="text" /></td>
</tr>
<tr>
<td></td>
<td></td>
<td><input name="Submit" value="Login" type="submit" /></td>
</tr>
</table>
</td>
</tr>
</table>
</form>
</body>
</html>
check_login.php
Codice: Seleziona tutto
<!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>Documento senza titolo</title>
</head>
<body>
<?
$host="localhost"; // Hostname
$username=""; // Mysql username
$password=""; // Mysql password
$db_name="gestione_login"; //Nome del Database
$tbl_name="members"; // Nome della Tabella
// Procedimento per connettersi al Database
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
// Nome utente e password inviate attraverso il form
$myusername=$_POST['myusername'];
$mypassword=$_POST['mypassword'];
$sql="SELECT * FROM $tbl_name WHERE username='$myusername' and password='$mypassword'";
$result=mysql_query($sql);
// Mysql_num_row is counting table row
$count=mysql_num_rows($result);
// If result matched $myusername and $mypassword, table row must be 1 row
if($count==1){
// Register $myusername, $mypassword and redirect to file "login_success.php"
session_register("myusername");
session_register("mypassword");
header("location:login_success.php");
}
else {
echo "Attenzione username o password errati";
}
?>
?>
</body>
</html>
login_success.php
Codice: Seleziona tutto
<!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>Documento senza titolo</title>
</head>
<body>
<?
// Controlla se la sessione è stata registrata, altrimenti rimanda alla pagina di login
// Questa prima parte dobbiamo inserirla in tutte le pagine che vogliamo proteggere con password prima di qualsiasi altra cosa
session_start();
if(!session_is_registered(myusername)){
header("location:main_login.php");
}
?>
?>
Login Successful
</body>
</html>
logout.php
Codice: Seleziona tutto
<!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>Documento senza titolo</title>
</head>
<body>
<?
session_start();
session_destroy();
?>
?>
</body>
</html>
ho creato un database con mysql con la tabella member in cui sto registrando la gente.
Che problema ho?
Schiacciando il pulsante "login" al momento mi appare questo errore:
Codice: Seleziona tutto
Parse error: syntax error, unexpected '?' in /var/www/checklogin.php on line 34Codice: Seleziona tutto
?>help me! (good)
- marko782
- Scoppiettante Seguace

- Messaggi: 284
- Iscrizione: sabato 24 marzo 2007, 12:53
- Località: Monza (MI)
Re: Schermata login su pagina web
Togli la parte in rossoelse {
echo "Attenzione username o password errati";
}
?>
- PetrizzelliGraphics
- Entusiasta Emergente

- Messaggi: 2273
- Iscrizione: giovedì 2 novembre 2006, 15:34
- Località: Verona
- Contatti:
Re: Schermata login su pagina web
eliminato...anche se sinceramente non capisco cosa sia quella riga!comunque l'errore persiste,adesso la riga di output nel browser è la seguente:marko782 ha scritto:Togli la parte in rossoelse {
echo "Attenzione username o password errati";
}
?>
Codice: Seleziona tutto
Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'www-data'@'localhost' (using password: NO) in /var/www/checklogin.php on line 15
cannot connectRe: Schermata login su pagina web
Il codice
Codice: Seleziona tutto
<!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>Documento senza titolo</title>
</head>
<body>Poi nel file checklogin.php devi impostare come utente e password quelli che utilizzi per connetterti al db gestione_login da localhost che sono vuoti.
- PetrizzelliGraphics
- Entusiasta Emergente

- Messaggi: 2273
- Iscrizione: giovedì 2 novembre 2006, 15:34
- Località: Verona
- Contatti:
Re: Schermata login su pagina web
il databse non ha un utente nè password comunque vi allego i file che è meglio (yes)prampa ha scritto: come dice marko782 dovunque trovi quel simbolo toglilo. Poi devi copiare il testo cosi' come e' indicato nel link, senza aggiungere nulla. Ricominica daccapo.
Il codicenon serve (al limite lo rimetti dopo che funziona solo dove c'e' html).Codice: Seleziona tutto
<!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>Documento senza titolo</title> </head> <body>
Poi nel file checklogin.php devi impostare come utente e password quelli che utilizzi per connetterti al db gestione_login da localhost che sono vuoti.
ho appena provato con i file che vi ho inviato...adesso se schiaccio login mi da questa cosa:
Codice: Seleziona tutto
$host="localhost"; // Hostname $username=""; // Mysql username $password=""; // Mysql password $db_name="gestione_login"; //Nome del Database $tbl_name="members"; // Nome della Tabella // Procedimento per connettersi al Database mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); // Nome utente e password inviate attraverso il form $myusername=$_POST['myusername']; $mypassword=$_POST['mypassword']; $sql="SELECT * FROM $tbl_name WHERE username='$myusername' and password='$mypassword'"; $result=mysql_query($sql); // Mysql_num_row is counting table row $count=mysql_num_rows($result); // If result matched $myusername and $mypassword, table row must be 1 row if($count==1){ // Register $myusername, $mypassword and redirect to file "login_success.php" session_register("myusername"); session_register("mypassword"); header("location:login_success.php"); } else { echo "Attenzione username o password errati"; }- Allegati
-
Pagine.zip- (2.18 KiB) Scaricato 28 volte
Re: Schermata login su pagina web
Il documento login_success.php cambialo con questo
Codice: Seleziona tutto
<!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>Documento senza titolo</title>
</head>
<body>
OK
</body>
</html>
Se ti da errori all'accesso crea un utente per l'accesso al db gestione_login e imposta user e password nel file checklogin.php
ciao
- PetrizzelliGraphics
- Entusiasta Emergente

- Messaggi: 2273
- Iscrizione: giovedì 2 novembre 2006, 15:34
- Località: Verona
- Contatti:
Re: Schermata login su pagina web
Grazie mille!
L'errore datomi è sempre lo stesso:
Codice: Seleziona tutto
Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'admin'@'localhost' (using password: YES) in /var/www/checklogin.php on line 8
cannot connect- Allegati
-
Login.zip- (1.96 KiB) Scaricato 31 volte
Re: Schermata login su pagina web
Si, da me vanno sin dall'inizio.swimmerino88 ha scritto: Oddio credo di aver fatto tutto quello che mi hai detto ma niente!da quello che ho capito il mio DB se non imposto IO password e username questo entra con admin admin...giusto?beh ecco i files modificati come hai detto a te vanno se lo provi sul tuo apache scusa?sennò sono veramente impedito! >:(
Grazie mille!
L'errore datomi è sempre lo stesso:Codice: Seleziona tutto
Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'admin'@'localhost' (using password: YES) in /var/www/checklogin.php on line 8 cannot connect
Forse pero' ho capito (in ogni caso nel file checklogin.php dopo <? della prima riga aggiungi "php", esempio <?php. Questo dipende dai parametri impostati nel file php.ini: cosi' dovrebbe funzionare sempre, anche su altre installazioni).
I valori admin, admin (che imposti in maschera) corrispondono a username e password che tu hai inserito nella tabella (come da insert presente nel link).
L'utente con cui tu ti colleghi a mysql è un'altra cosa: con l'accoppiata user/password (che dovrai impostare dentro il file checklogin.php) tu ti colleghi a mysql e verifichi che esista l'occorrenza nella tabella corrispondente ai valori digitati in mappa. Infatti l'errore ti riporta "accesso negato all'utente admin". Quando hai creato il db gestione_login hai acceduto a mysql con uno username e una password. Per accedere al db nella connessione usa quell'utente e quella password. Se per caso usi le password di default, crea un nuovo utente e password e usali nella connessione.
ciao
- PetrizzelliGraphics
- Entusiasta Emergente

- Messaggi: 2273
- Iscrizione: giovedì 2 novembre 2006, 15:34
- Località: Verona
- Contatti:
Re: Schermata login su pagina web
Poi siccome avevo il database con user e password di default ho dato il seguente comando:
dove per fabio io ho messo il mio nome...questo l'ho preso da un sitoCREATE USER fabio@localhost IDENTIFIED BY 'password';
poi ho scritto:
Codice: Seleziona tutto
SET PASSWORD = PASSWORD('pw')Codice: Seleziona tutto
SET PASSWORD FOR fabio@localhost = PASSWORD('pw');Adesso stavo accedendo al mio database su linux ma ho dei problemi:
Codice: Seleziona tutto
swimmerino88@Kubuntu:/var/www$ sudo mysql gestione_login
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
Codice: Seleziona tutto
Copyright (C) 2002 MySQL AB
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to modify and redistribute it under the GPL license
Usage: mysql [OPTIONS] [database]
-?, --help Display this help and exit.
-I, --help Synonym for -?
--auto-rehash Enable automatic rehashing. One doesn't need to use
'rehash' to get table and field completion, but startup
and reconnecting may take a longer time. Disable with
--disable-auto-rehash.
-A, --no-auto-rehash
No automatic rehashing. One has to use 'rehash' to get
table and field completion. This gives a quicker start of
mysql and disables rehashing on reconnect. WARNING:
options deprecated; use --disable-auto-rehash instead.
-B, --batch Don't use history file. Disable interactive behavior.
(Enables --silent)
--character-sets-dir=name
Directory where character sets are.
--default-character-set=name
Set the default character set.
-C, --compress Use compression in server/client protocol.
-#, --debug[=#] This is a non-debug version. Catch this and exit
-D, --database=name Database to use.
--delimiter=name Delimiter to be used.
-e, --execute=name Execute command and quit. (Disables --force and history
file)
-E, --vertical Print the output of a query (rows) vertically.
-f, --force Continue even if we get an sql error.
-g, --no-named-commands
Named commands are disabled. Use \* form only, or use
named commands only in the beginning of a line ending
with a semicolon (;) Since version 10.9 the client now
starts with this option ENABLED by default! Disable with
'-G'. Long format commands still work from the first
line. WARNING: option deprecated; use
--disable-named-commands instead.
-G, --named-commands
Enable named commands. Named commands mean this program's
internal commands; see mysql> help . When enabled, the
named commands can be used from any line of the query,
otherwise only from the first line, before an enter.
Disable with --disable-named-commands. This option is
disabled by default.
-i, --ignore-spaces Ignore space after function names.
--local-infile Enable/disable LOAD DATA LOCAL INFILE.
-b, --no-beep Turn off beep on error.
-h, --host=name Connect to host.
-H, --html Produce HTML output.
-X, --xml Produce XML output
--line-numbers Write line numbers for errors.
-L, --skip-line-numbers
Don't write line number for errors. WARNING: -L is
deprecated, use long version of this option instead.
--no-pager Disable pager and print to stdout. See interactive help
(\h) also. WARNING: option deprecated; use
--disable-pager instead.
--no-tee Disable outfile. See interactive help (\h) also. WARNING:
option deprecated; use --disable-tee instead
-n, --unbuffered Flush buffer after each query.
--column-names Write column names in results.
-N, --skip-column-names
Don't write column names in results. WARNING: -N is
deprecated, use long version of this options instead.
-O, --set-variable=name
Change the value of a variable. Please note that this
option is deprecated; you can set variables directly with
--variable-name=value.
--sigint-ignore Ignore SIGINT (CTRL-C)
-o, --one-database Only update the default database. This is useful for
skipping updates to other database in the update log.
--pager[=name] Pager to use to display results. If you don't supply an
option the default pager is taken from your ENV variable
PAGER. Valid pagers are less, more, cat [> filename],
etc. See interactive help (\h) also. This option does not
work in batch mode.
-p, --password[=name]
Password to use when connecting to server. If password is
not given it's asked from the tty. WARNING: This is
insecure as the password is visible for anyone through
/proc for a short time.
-P, --port=# Port number to use for connection.
--prompt=name Set the mysql prompt to this value.
--protocol=name The protocol of connection (tcp,socket,pipe,memory).
-q, --quick Don't cache result, print it row by row. This may slow
down the server if the output is suspended. Doesn't use
history file.
-r, --raw Write fields without conversion. Used with --batch.
--reconnect Reconnect if the connection is lost. Disable with
--disable-reconnect. This option is enabled by default.
-s, --silent Be more silent. Print results with a tab as separator,
each row on new line.
-S, --socket=name Socket file to use for connection.
-t, --table Output in table format.
-T, --debug-info Print some debug info at exit.
--tee=name Append everything into outfile. See interactive help (\h)
also. Does not work in batch mode.
-u, --user=name User for login if not current user.
-U, --safe-updates Only allow UPDATE and DELETE that uses keys.
-U, --i-am-a-dummy Synonym for option --safe-updates, -U.
-v, --verbose Write more. (-v -v -v gives the table output format).
-V, --version Output version information and exit.
-w, --wait Wait and retry if connection is down.
--connect_timeout=# Number of seconds before connection timeout.
--max_allowed_packet=#
Max packet length to send to, or receive from server
--net_buffer_length=#
Buffer for TCP/IP and socket communication
--select_limit=# Automatic limit for SELECT when using --safe-updates
--max_join_size=# Automatic limit for rows in a join when using
--safe-updates
--secure-auth Refuse client connecting to server if it uses old
(pre-4.1.1) protocol
--show-warnings Show warnings after every statement.
Default options are read from the following files in the given order:
/etc/mysql/my.cnf ~/.my.cnf /etc/mysql/my.cnf
The following groups are read: mysql client
The following options may be given as the first argument:
--print-defaults Print the program argument list and exit
--no-defaults Don't read default options from any options file
--defaults-file=# Only read default options from the given file #
--defaults-extra-file=# Read this file after the global files are read
Variables (--variable-name=value)
and boolean options {FALSE|TRUE} Value (after reading options)
--------------------------------- -----------------------------
auto-rehash TRUE
character-sets-dir (No default value)
default-character-set latin1
compress FALSE
database (No default value)
delimiter ;
vertical FALSE
force FALSE
named-commands FALSE
local-infile FALSE
no-beep FALSE
host (No default value)
html FALSE
xml FALSE
line-numbers TRUE
unbuffered FALSE
column-names TRUE
sigint-ignore FALSE
port 3306
prompt mysql>
quick FALSE
raw FALSE
reconnect TRUE
socket /var/run/mysqld/mysqld.sock
table FALSE
debug-info FALSE
user (No default value)
safe-updates FALSE
i-am-a-dummy FALSE
connect_timeout 0
max_allowed_packet 16777216
net_buffer_length 16384
select_limit 1000
max_join_size 1000000
secure-auth FALSE
show-warnings FALSE
N.B:impostanto user e password invece dal file che mi hai detto,dopo aver inserito nome_utente e password e aver schiacciato il tasto login ottengo:
Codice: Seleziona tutto
cannot select DB- PetrizzelliGraphics
- Entusiasta Emergente

- Messaggi: 2273
- Iscrizione: giovedì 2 novembre 2006, 15:34
- Località: Verona
- Contatti:
Chi c’è in linea
Visualizzano questa sezione: Google [Bot] e 2 ospiti