Ciao, ho un problemone con php.
devo creare un form di autenticazione con user e password che mi permette di accedere al database di consultazione di libri presenti in una biblioteca.
premetto che sono alle primissime armi con php!!!
allora, ho creato il form, ma devo capire come faccio a connetterlo al db, a dare messaggio di errore se l'utente non è registrato, e come permetto all'utente vuovo di registrarsi inserendo nel db una nuova user e password. grazie mille
questo è il codice che ho scritto fino adesso ( e credo sia pieno di errori)
[php]
<?php
require_once("config.php");
require_once("funzioni.php");
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/xhtml11/DTD/html11.dtd">
<html>
<head>
<title>form</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<?php
if ($_SERVER ["REQUEST_METHOD] =="GET")
{
?>
<h4>consulta i testi</h4>
<form method="post" <?php echo "action="",$_SERVER ["PHP_SELF"], """; ?> >
Username: <input type="text" name="utente" size="10"/>
Password: <input type="text" name="password" size="10"/>
<br/>
<input type="submit" value="entra"/>
<input type="submit" value="registrati"/>
</form>
<?
}
else
if (!utenteValido($_POST["utente"], $_POST["password"]))
{
echo "non sei registrato";
?>
<?
$connessione = mysql_connect ("localhost" ,"root", "")
or die ("connessione non riuscita");
mysql_select_db ("registrati")
or die ("selezione del db non riuscita");
?>
</body>
</html>
[/php]