Ciao, ho scaricato uno script per l'invio di email dal sito, l'ho scaricato qui sul html.it, nella sezione di php, è il primo.
Io non conosco nulla di php, ma questo essendo molto semplice ho capito come fare quelle quattro personalizzazioni che mi servivano.
Vorrei però aggiungere un ritorno al sito dop l'invio , cioè se l'invio della mail è andato si pare la pagina con i ringraziamenti, vorrei che lì sia visualizzato anche un link per tornare indietro al sito.
Potete aiutarmi, grazie.
Ecco il codice:
Codice PHP:
<?php
$receiverMail = "your@email.com";
$name = ltrim(rtrim(strip_tags(stripslashes($_POST['name']))));
$email = ltrim(rtrim(strip_tags(stripslashes($_POST['email']))));
$subject = ltrim(rtrim(strip_tags(stripslashes($_POST['subject']))));
$msg = ltrim(rtrim(strip_tags($_POST['msg'])));
$ip = getenv("REMOTE_ADDR");
$msgformat = "From: $name ($ip)\nEmail: $email\n\n$msg";
// VALIDATION
if(empty($name) || empty($email) || empty($subject) || empty($msg)) {
echo "<h3>The email was not sent</h3>
Please fill all the required fields</p>";
}
elseif(!ereg("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email)) {
echo "<h3>The email was not sent</h3>
The email address is invalid</p>";
}
else {
mail($receiverMail, $subject, $msgformat, "From: $name <$email>");
echo "<h3>The email has been sent!</h3>
I will get back to you as soon as possible.</p>"; }
?>
ed il form
Codice PHP:
<form method="post" action="send.php">
Name:
<input name="name" type="text" size="30" maxlength="40" />
Email:
<input name="email" type="text" size="30" maxlength="40" />
Subject:
<input name="subject" type="text" size="30" maxlength="40" />
Message:
<textarea name="msg" cols="50" rows="6"></textarea>
<input type="reset" value="Reset" /><input type="submit" value="Send" />
</form>