- Home
- Categorie
- Coding e Sistemistica
- PHP
- form php con anteprima con privacy
-
form php con anteprima con privacy
ciao a tutti
posto qui' un form .....
si accettano consigli come migliorarlo e renderlo piu' funzionale se si puo'....PAGINA FORM
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Documento senza titolo</title>
<script>
//pop-up window for preview
function popup() {
win = window.open('','myWin','toolbars=0,width=350,height=350');
document.post.action='preview.php';
document.post.target='myWin';
document.post.submit();
document.post.action='validate.php';
document.post.target='_self';
}
</script>
<script>
<!--
function checkData()
{
var correct = true
if (document.post.nome.value == "") {correct = false; alert("Inserisci il tuo nome !")}
if (document.post.cognome.value == "") {correct = false; alert("Inserisci il tuo cognome !")}
if (document.post.localita.value == "") {correct = false; alert("Inserisci localita' !")}
if (document.post.email.value == "") {correct = false; alert("Inserisci il tuo indirizzo di e-mail !")}
if ((document.post.email.value.indexOf("@") == -1 ) && (document.post.email.value !== "")) {correct = false; alert("Indirizzo e-mail non valido !")}
if (document.post.oggetto.value == "") {correct = false; alert("Inserisci oggetto !")}
if (document.post.messaggio.value == "") {correct = false; alert("Inserisci messaggio !")}
if (document.post.si.checked == "") {correct = false; alert("Devi accettare le condizioni sulla privacy !")}
return correct
}
//-->
</script></head>
<body>
<form method="post" name="post" action="validate.php" target="_self" >
Nome *<br />
<input type="text" name="nome" id="nome">
<br />
<br />
Cognome *<br />
<input type="text" name="cognome" id="cognome">
<br />
<br />
Localita'<br />
<label>
<input type="text" name="localita" id="localita" />
</label>
<br />
<br />
Email *<br />
<label>
<input type="text" name="email" id="email" />
</label>
<br />
<br />
Oggetto *<br />
<label>
<input type="text" name="oggetto" id="oggetto" />
</label>
<br />
<br />
<label></label>
<label></label>
Messaggio
<label> *<br />
<textarea name="messaggio" id="messaggio" cols="45" rows="5"></textarea>
</label>
<br />
<br />
Condizioni sulla privacy *<br />
<label>
<input type="radio" name="si" id="radio" value="si" />
</label>
si accetto condizioni sulla privacy dei dati<br />
<br />
Tutti i campi contrassegnati con l'asterisco sono obbligatori<br />
<br />
<input type="button" name="post" class="submit" value="anteprima" onclick="popup(); " />
<label>
<input type="reset" name="button" id="button" value="Ripristina" />
</label>
<input type="submit" name="post" class="submit" value="Submit" onclick="return checkData()" />
</form>
</p>
<p> </p>
<p> </p>
</body>
</html>pagina preview.php
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Documento senza titolo</title><style type="text/css">
</span>\n<span class="testo">$t2</span></br></br><span class="intestazioni">Localita' </span><span class="testo">\n$t4</span></br></br><span class="intestazioni">Oggetto </span></br><span class="testo">\n$t6</span></br></br><span class="intestazioni">Accetti condizioni sulla privacy ::: </span><span class="testo">\n$t7</span></br>";
<!--
.intestazioni {
font-family: Geneva, Arial, Helvetica, sans-serif;
font-size: 12px;
font-weight: bold;
color: #999999;
}
.testo {
font-family: Geneva, Arial, Helvetica, sans-serif;
font-size: 12px;
font-style: italic;
font-weight: normal;
font-variant: normal;
color: #CC0000;
}
-->
</style>
</head>
<body>
<?php
$t1=$_POST["nome"];
$t2=$_POST["cognome"];
$t3=$_POST["localita"];
$t4=$_POST["email"];
$t5=$_POST["oggetto"];
$t6=$_POST["messaggio"];
$t7=$_POST["si"];
echo "<span class="intestazioni">Nome
?>
</p>
<p> </p>
<p> </p>
</body>
</html>pagina validate.php
<?php
// L'INDIRIZZO DEL DESTINATARIO DELLA MAIL
$to = "[email protected]";
// IL SOGGETTO DELLA MAIL
$subject = "*Modulo proveniente dal sito maxxxx.it";
// COSTRUZIONE DEL CORPO DEL MESSAGGIO
$body = "Contenuto:\n\n";
$body .= "Dati personali ;<br>nome: " . trim(stripslashes($_POST["nome"])) . "\n";
$body .= "cognome: " . trim(stripslashes($_POST["cognome"])) . "\n";
$body .= "Localita': " . trim(stripslashes($_POST["localita"])) . "\n";
$body .= "Oggetto: " . trim(stripslashes($_POST["oggetto"])) . "\n";
$body .= "Messaggio: " . trim(stripslashes($_POST["messaggio"])) . "\n";
$body .= "mail: " . trim(stripslashes($_POST["email"])) . "\n";
$body .= "si: " . trim(stripslashes($_POST["si"])) . "\n";// INVIO DELLA MAIL
if(@mail($to, $subject, $body))
?>fatemi sapere se vi sembra utile o cosa ne pensate.....
ciao