Codice PHP:
<?php
$username = $HTTP_POST_VARS["username"];
$password = $HTTP_POST_VARS["password"];
$server = "localhost";
$username = "mionome";
$password = "mia password";
$database = "my_mionome";
if ($database == ""){
$query = "use members";
if (mysql_query($query) == null){
$query = "CREATE DATABASE members";
mysql_query($query);
$conn = mysql_connect($server,$username,$password) or die ("Could not connect MySQL");
mysql_select_db($database,$conn) or die ("Could not open database");
}
else{
$database= "members";
$conn = mysql_connect($server,$username,$password) or die ("Could not connect MySQL");
mysql_select_db($database,$conn) or die ("Could not open database");
}
}
else{
$conn = mysql_connect($server,$username,$password) or die ("Could not connect MySQL");
mysql_select_db($database,$conn) or die ("Could not open database");
}
$query = "INSERT INTO `utenti` ( `username` , `password’ )
VALUES ('$username','$password')";
mysql_query($query)
or die ( "Impossibile aggiungere dati alla tabella \"utenti\" : ".mysql_error() );
$result = mysql_query($query);
if ($result == 1){header("location: benvenuto.htm");}
?>