Originariamente inviato da satifal
Senza codice come si fa ad individuare il problema?
Sorry
Inserimento dati
Codice PHP:
<?php require_once('Connections/man.php'); ?>
<?php
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $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"] == "ins_man")) {
$insertSQL = sprintf("INSERT INTO manifesto (Nome, Cognome, Professione) VALUES (%s, %s, %s)",
GetSQLValueString($_POST['Nome'], "int"),
GetSQLValueString($_POST['cognome'], "int"),
GetSQLValueString($_POST['professione'], "int"));
mysql_select_db($database_man, $man);
$Result1 = mysql_query($insertSQL, $man) or die(mysql_error());
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Documento senza titolo</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<div align="center">
<form action="<?php echo $editFormAction; ?>" method="POST" name="ins_man" id="ins_man">
<div align="left">
Nome:
<input name="Nome" type="text" id="Nome">
</p>
Cognome:
<input name="cognome" type="text" id="cognome">
</p>
Professione*:
<input name="professione" type="text" id="professione">
</p>
<input type="submit" name="Submit" value="Supporta Marco Stella">
</p>
</div>
<input type="hidden" name="MM_insert" value="ins_man">
</form>
</div>
</body>
</html>
Lettura da database
Codice PHP:
<?php require_once('Connections/man.php'); ?>
<?php
mysql_select_db($database_man, $man);
$query_man = "SELECT Nome, Cognome, Professione FROM manifesto";
$man = mysql_query($query_man, $man) or die(mysql_error());
$row_man = mysql_fetch_assoc($man);
$totalRows_man = mysql_num_rows($man);
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Documento senza titolo</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<div align="center">
<?php do { ?>
<?php echo $row_man['Nome']; ?> <?php echo $row_man['Cognome']; ?> <?php echo $row_man['Professione']; ?>,
<?php } while ($row_man = mysql_fetch_assoc($man)); ?>
</div>
</body>
</html>
<?php
mysql_free_result($man);
?>
Grazie mille