Salve a tutti, dopo infiniti tentativi sono riuscito a costruire una pagina con form per l'inserimento di alcuni dati da parte degli utenti del sito. Il problema che sto riscontrando ora è che quando vado a caricare la pagina sul mio server (altervista) mi viene restituito un messaggio di errore "database non trovato" riporto di seguito il codice:
<?php require_once('Connections/fabio.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
$insertSQL = sprintf("INSERT INTO fabio (nome, cognome, indirizzo, telefono) VALUES (%s, %s, %s, %s)",
GetSQLValueString($_POST['nome'], "text"),
GetSQLValueString($_POST['cognome'], "text"),
GetSQLValueString($_POST['indirizzo'], "text"),
GetSQLValueString($_POST['telefono'], "double"));
mysql_select_db($database_fabio, $fabio);
$Result1 = mysql_query($insertSQL, $fabio) or die(mysql_error());
}
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
$insertSQL = sprintf("INSERT INTO fabio (nome, cognome, indirizzo, telefono) VALUES (%s, %s, %s, %s)",
GetSQLValueString($_POST['nome'], "text"),
GetSQLValueString($_POST['cognome'], "text"),
GetSQLValueString($_POST['indirizzo'], "text"),
GetSQLValueString($_POST['telefono'], "double"));
mysql_select_db($database_fabio, $fabio);
$Result1 = mysql_query($insertSQL, $fabio) or die(mysql_error());
}
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
$insertSQL = sprintf("INSERT INTO fabio (nome, cognome, indirizzo, telefono) VALUES (%s, %s, %s, %s)",
GetSQLValueString($_POST['nome'], "text"),
GetSQLValueString($_POST['cognome'], "text"),
GetSQLValueString($_POST['indirizzo'], "text"),
GetSQLValueString($_POST['telefono'], "double"));
mysql_select_db($database_fabio, $fabio);
$Result1 = mysql_query($insertSQL, $fabio) or die(mysql_error());
}
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
$insertSQL = sprintf("INSERT INTO fabio (nome, cognome, indirizzo, telefono) VALUES (%s, %s, %s, %s)",
GetSQLValueString($_POST['nome'], "text"),
GetSQLValueString($_POST['cognome'], "text"),
GetSQLValueString($_POST['indirizzo'], "text"),
GetSQLValueString($_POST['telefono'], "int"));
mysql_select_db($database_fabio, $fabio);
$Result1 = mysql_query($insertSQL, $fabio) or die(mysql_error());
}
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
$insertSQL = sprintf("INSERT INTO fabio (nome, cognome, indirizzo, telefono) VALUES (%s, %s, %s, %s)",
GetSQLValueString($_POST['nome'], "text"),
GetSQLValueString($_POST['cognome'], "text"),
GetSQLValueString($_POST['indirizzo'], "text"),
GetSQLValueString($_POST['telefono'], "double"));
mysql_select_db($database_fabio, $fabio);
$Result1 = mysql_query($insertSQL, $fabio) or die(mysql_error());
}
?><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Documento senza titolo</title>
</head>
<body>
<form name="form1" method="POST" action="<?php echo $editFormAction; ?>">
<table width="600" border="1" cellspacing="0" cellpadding="0">
<tr>
<td width="118"><div align="center">nome</div></td>
<td width="476"><label>
<input type="text" name="nome" id="nome">
</label></td>
</tr>
<tr>
<td><div align="center">cognome</div></td>
<td><label>
<input type="text" name="cognome" id="cognome">
</label></td>
</tr>
<tr>
<td><div align="center">indirizzo</div></td>
<td><label>
<input type="text" name="indirizzo" id="indirizzo">
</label></td>
</tr>
<tr>
<td><div align="center">telefono</div></td>
<td><label>
<input type="text" name="telefono" id="telefono">
</label></td>
</tr>
<tr>
<td><div align="center">testo inserzione</div></td>
<td><label>
<textarea name="textarea" id="textarea" cols="45" rows="5"></textarea>
</label></td>
</tr>
<tr>
<td><div align="center">invio</div></td>
<td><label>
<input type="submit" name="button" id="button" value="Invia">
</label></td>
</tr>
</table>
<input type="hidden" name="MM_insert" value="form1">
</form>
</body>
</html>
Qualcuno saprebbe indicarmi cosa c'è di sbagliato? Mille grazie