Come non detto...
allora il form e' questo:
Codice PHP:
<?
include 'conn.inc';
include 'title.inc';
$nome="Contatti";
?>
[url="contatti_en.php><img"][/url]
<?
include 'title2.inc';
?>
<script language="javascript">
<!--
function Modulo() {
var nome = document.modulo.nome.value;
var email = document.modulo.email.value;
var messaggio = document.modulo.messaggio.value;
var email_reg_exp = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-]{2,})+\.)+([a-zA-Z0-9]{2,})+$/;
if ((nome == "") || (nome == "undefined")) {
alert("Il campo nome e' obbligatorio.");
document.modulo.nome.focus();
return false;
}
else if ((email == "") || (email == "undefined")) {
alert("Il campo E-mail e' obbligatorio.");
document.modulo.email.focus();
return false;
}
else if (!email_reg_exp.test(email) || (email == "") || (email == "undefined")) {
alert("Inserire un indirizzo email corretto.");
document.modulo.email.select();
return false;
}
else if ((messaggio == "") || (messaggio == "undefined") || (messaggio.indexOf("Inserire il messaggio") != (-1))) {
alert("Il campo Messaggio obbligatorio.");
document.modulo.messaggio.focus();
return false;
}
else {
document.modulo.action = "invia.php";
document.modulo.submit();
}
}
//-->
</script>
<?
include 'sin.inc';
?>
<div id=blink>Scrivimi</div>
<?
include 'cen.inc';
?>
<form method="POST" action="invia.php" name="modulo">
<table border=0 width=70%>
<tr><td colspan=4 class=testo>
<h2>Contatti</h2>
</td>
</tr>
<tr>
<td colspan=2 class=testo>Nome</td>
<td colspan=2 >
<input type="text" name="nome"></td>
</tr>
<tr>
<td colspan=2 class=testo>Email</td>
<td colspan=2 >
<input type="text" name="email"></td>
</tr>
<tr>
<td colspan=2 class=testo valign=top>Messaggio</td>
<td colspan="2">
<textarea name="messaggio" rows="5" cols="40"></textarea>
</td>
</tr>
<tr>
<td colspan="4" align="center">
<input type="button" class="txt" value="Invia" onClick="Modulo()">
<input type="reset" class="txt" value="Cancella">
</td>
</tr>
</table>
</form>
<?
include 'end.inc';
?>
il file che dovrebbe scrivere i dati (invia.php) e'
Codice PHP:
<?
include 'conn.inc';
include 'title.inc';
$nome="Contatti";
$_nome = $_GET['nome'];
$_email = $_GET['email'];
$_messaggio = $_GET['messaggio'];
?>
[url="invia_en.php><img"][/url]
<?
include 'title2.inc';
include 'sin2.inc';
include 'cen.inc';
$d1=date('d/m/Y');
$result = mysql_query("INSERT INTO `msg` (`nome`, `email`, `messaggio`,`data`) VALUES ('$_nome','$_email','$_messaggio','$d1')") or die(mysql_error());
if($result) {
echo "</center><p class=testo>Grazie per aver inserito il messaggio";
} else {
echo mysql_error();
}
include 'end.inc';
?>
ma mi da' questo errore:
Codice PHP:
Notice: Undefined index: nome in /www/10gbfreehost.com/d/y/d/dydale/htdocs/invia.php on line 5
Notice: Undefined index: email in /www/10gbfreehost.com/d/y/d/dydale/htdocs/invia.php on line 6
Notice: Undefined index: messaggio in /www/10gbfreehost.com/d/y/d/dydale/htdocs/invia.php on line 7