grazie, ho modificato cosi ma non funziona, non riesco a inserire dati nel db
codice:
<html><head>
<meta charset="utf-8"/>
<title>registraKsComune</title>
</head>
<body>
<?php
//raccologo i dati dalla form
if(isset($_POST["cognome"]) && isset($_POST["nome"])&& isset($_POST["elencoComuni"])&& isset($_POST["user"])&& isset($_POST["psw"]))
{
$cognome=$_POST["cognome"];
$nome=$_POST["nome"];
$ksComune=$_POST["elencoComuni"];
$user=$_POST["user"];
$password=$_POST["psw"];
}
//connessione server e connessione DB
$conn=mysql_connect("localhost","root","");
if(!$conn)
{
echo "server al momento non disponibile";
echo "<a href='inserimentoCombo.php'>cliccare qui</a>";
}
if (!mysql_select_db("utenti"))
{
echo "Impossibile aprire db utenti";
}
// ora lancio la query
if(isset($_POST["cognome"]) && isset($_POST["nome"])&& isset($_POST["elencoComuni"])&& isset($_POST["user"])&& isset($_POST["psw"]))
{
$comando="insert * into accessi (cognome,nome,userName,password,ksComune)
values ('$cognome', '$nome','$user','$password','$ksComune')";
if (! mysql_query($comando))
{
echo "Inserimento fallito <br/>";
}
}
// chiudo la connessione
mysql_close($conn);
print "<a href='inserimentoCombo.php'>Nuova registrazione</a>";
?>
</body>
</html>
NON MI inserisce nulla nel db mi da inserimento fallito
Questa è la pagina di inserimento
codice:
<html>
<head>
<meta charset="utf-8"/>
<title>inserimentoCombo</title>
</head>
<body>
<?php
$conn=mysql_connect("localhost","root","");
// prima verifico se la connessione al server è ok
if(!$conn)
{
echo "server al momento non disponibile";
echo "<a href='inserimentoCombo.php'>cliccare qui</a>";
}
// poi verifico la connessione al database
if (!mysql_select_db("utenti"))
{
echo "Impossibile aprire db utenti";
}
// ora lancio la query
$comando="select * from comuni";
$result=mysql_query($comando);
?>
<form method="post" name="registra" action="registraKsComune.php" id="registra">
<div style="width:45%">
<fieldset>
<legend align="left">inserimento</legend>
<table cellpadding="5" cellspacing="5" width="45%">
<tr>
<td>Cognome</td>
<td><input type="text" name="cognome" id="cognome"/></td>
</tr>
<tr>
<td>Nome</td>
<td><input type="text" name="nome" id="nome"/></td>
</tr>
<tr>
<td>Comune</td>
<td><select name="elencoComuni">
<?php
while($dati=mysql_fetch_assoc($result))
print "<option value= '$dati[id]'>$dati[nome]</option>";
?>
</td>
</tr>
<tr>
<td>User Name</td>
<td><input type="text" name="user" id="user"/></td>
</tr>
<tr>
<td>Password</td>
<td><input type="text" name="psw" id="password"/></td>
</tr>
<tr>
<td><input type="submit" name="registra" value="registra"/></td>
</tr>
</table>
</fieldset>
</div>
</form>
</body>
</html>
[/code]