- Codice: Seleziona tutto
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>senderPage</title>
</head>
<body>
<?php
if ((trim($_POST['object']) != "") && (trim($_POST['body']) != "") && (trim($_POST['mail']) != "")) {
$to = "savino.liguori@gmail.com";
$headers = "From: " . $_POST['mail'] . "\n";
$subject = "Mail da Cretinate 4 Dummies";
$redirect_1 = "http://cretinate4dummies.blogspot.com/p/graziemail.html";
$redirect_2 = "http://cretinate4dummies.blogspot.com/p/errore.html";
$body = "Contenuto del modulo:\n\n";
$body .= "Inviata da: " . trim(stripslashes($_POST["mail"])) . "\n";
$body .= "Oggetto: " . trim(stripslashes($_POST["object"])) . "\n";
$body .= "testo: " . trim(stripslashes($_POST["body"])) . "\n";
mail($to, $subject, $body, $headers);
echo "<script language=\"JavaScript\">\n";
echo "window.location.href=(\"$redirect_1\");\n";
echo "</script>";
}
else {
echo "<script language=\"JavaScript\">\n";
echo "window.location.href=(\"$redirect_2\");\n";
echo "</script>";
}
?>
</body>
</html>
La mia intenzione è riportare la pagina di errore (indicata in $redirect_2) nel caso che anche uno solo dei campi sia vuoto.
Se il form è compilato correttamente, funziona benissimo.
Se forzo un errore, la pagina php va in un loop che non finisce mai e non fa il redirect in $redirect_2
Considerando che l'ho modificato molto "alla bell'è meglio", sapete darmi qualche soluzione?


