Il codice qui sotto sembra funzionare se non che quando vado ad inserire tutti i dati del form costruito, restituisce il seguente errore
You have an error in your SQL syntax near '='pampa'' at line 1
dove pampa è il nome che io assegno allo username.
<html>
<head>
<title>Registrazione</title>
<meta http-equiv="content-type"
content="text/html; charset=iso-8859-1" />
</head>
<body>
<h1>First Access</h1>
<?php
//Connessione a MySql.
include $_SERVER['localhost'].'/includes/connect_Mysql.inc.php';
//Creazione del DB Fantacalcio.
include $_SERVER['localhost'].'/includes/create_DB.inc.php';
//Selezione del DB.
include $_SERVER['localhost'].'/includes/connect_DB.inc.php';
//Creazione tabella per Amministratore
include $_SERVER['localhost'].'/includes/create_admin_table.inc.php';
if( isset($_POST['submit']) && $_POST['submit']== "Register")
{
if( $_POST['username'] != "" &&
$_POST['password'] != "" &&
$_POST['nome'] != "" &&
$_POST['cognome'] != "" &&
$_POST['email'] != ""
)
{
$sql1="SELECT username FROM admin".
"WHERE username='".$_POST['username']."';";
$result=mysql_query($sql1) or die(mysql_error());
if(mysql_num_rows($result) == 0)
{
$sql2 = "INSERT INTO admin(username, password,".
"nome,cognome, email)".
"VALUES('".$_POST['username']."',".
"(PASSWORD('".$_POST['password']."')), '".
$_POST['nome']."', '".$_POST['cognome'].
"','".$_POST['email']."'";
$result=mysql_query($sql2) or die (mysql_error());
?>
Grazie, <?php echo $_POST['nome']."".
$_POST['cognome']; ?> per la registrazione!
<?php
header("Refresh: 5; URL = main_ins.php");
echo "La tua registrazione è stata completata!".
"Verrai inviato alla pagina costruzione del gioco!
";
echo"(Se il tuo browser non supporta questo,".
"<a href=\"main_ins.php\">click here</a>)";
die();
}
} else
{
?>
<font color="#FF0000">Non tutti i campi sono stati inseriti!</font>
<form action="register.php" method="post">
Reinserisci i tuoi dati mancanti:</p>
Username: <input type="text" name="username"
value="<?php echo $_POST['username']; ?>">
Password: <input type="password" name="password"
value="<?php echo $_POST['password']; ?>">
Nome: <input type="text" name="nome"
value="<?php echo $_POST['nome']; ?>">
Cognome: <input type="text" name="cognome"
value="<?php echo $_POST['cognome']; ?>">
Email: <input type="text" name="email"
value="<?php echo $_POST['email']; ?>">
<input type="submit" name="submit" value="Register">
<input type="reset" value="Clear">
</form>
</p>
<?php
}
}else {
?>
Benvenuto nella pagina di registrazione!
Username, Password, Nome e Cognome sono necessari !
<form action="register.php" method="post">
Username: <input type="text" name="username">
Password: <input type="password" name="password">
Nome: <input type="text" name="nome">
Cognome: <input type="text" name="cognome">
Email: <input type="text" name="email" >
<input type="submit" name="submit" value="Register">
<input type="reset" value="Clear">
</form>
</p>
<?php
}
?>
</body>
</html>