Ho creato un modulo di registrazione, ma non mi registra gli utenti nel database..
questo il form in html:
questa la pagina registrato.php
PHP:
questo è il file config.php di connessione al database:
<?
//connessione al database
$host = "localhost";
$username = "mateky";
$password = "password";
$database = "my_mateky";
//connessione a MySQL
@mysql_connect($host, $username, $password) or die ("Impossibile connettersi al database" . mysql_error());
//selezione del database
@mysql_select_db($database) or die ("Impossibile selezionare il database " . mysql_error());
?>
questo il form in html:
HTML:
<html>
<head><title>Registrazione</title></head>
<body>
<form name="registrazione" action="registrato.php" method="post">
<table border="0" cellspacing="5" cellpadding="5">
<tr>
<td>Nick:</td><td><input type="text" name="nick" size="35" maxlength="40" value=""></td>
</tr><tr>
<td>Password:</td><td><input type="password" name="password" size="35" maxlength="40" value=""></td>
</tr><tr>
<td>E-mail:</td><td><input type="text" name="email" size="35" maxlength="40" value=""></td>
</tr><tr>
<td>Età:</td><td><input type="text" name="eta" maxlenght="2" size="35"></td>
</tr><tr>
<td>Sito web:</td><td><input type="text" name="sitoweb" maxlenght="40" size="35">
</tr><tr>
<td>Pagina facebook</td><td><input type="text" name="pagina_facebook" maxlenght="40" size="35">
</tr><tr>
<td>Twitter:<input type="text" name="twitter" maxlenght="40" size="35">
</tr><tr>
Immagine del profilo:<input type="file" name="immagine_profilo">
</tr><tr>
<tr><td></td><td><input type=submit value="Invia i Dati"> <input type=reset value="Cancella tutto"></td></tr>
</table>
</form>
</body>
</html>
questa la pagina registrato.php
PHP:
<php
require 'config.php';
$nick=[$_POST('nick')];
$password=[$_POST('password')];
$email=[$_POST('email')];
$eta=[$_POST('eta')];
$sitoweb=[$_POST('sitoweb')];
$pagina_facebook=[$_POST('pagina_facebook')];
$twitter=[$_POST('twitter')];
$immagine_profilo=[$_POST('immagine_profilo')];
if(isset($_POST[('nick')]) || (isset($_POST[('password')]))
{
$query = "INSERT INTO profilo (nick, password, email, eta, sitoweb, pagina_facebook, twitter, immagine_profilo) values ('$nick', '$password', '$email', '$eta', '$sitoweb', '$pagina_facebook', '$twitter', '$immagine_profilo')")
or die (mysql_error());
echo "dati inseriti correttamente";
}
else
{
echo "errore nell inserimento dei dati";
}
?>
Ultima modifica: