- Home
- Categorie
- Coding e Sistemistica
- Coding
- Form mail con validazione lo controllate please ?
-
-
non mi considera nessuno
-
ciao
con questo codice
if(empty($nome) || empty($cognome) || empty($citta) || empty($email) || empty($oggetto) || empty($msg)) {
echo "<h3>L'email non è stata inviata</h3><p>Riempite tutti i campi richiesti Grazie</p>";
}verifichi che nessuno dei campi sia vuoto. se tutti i campi sono vuoti procede con l'analisi dell'indirizzo email ed infine con l'invio della mail stessa utilizzando però un messaggio che non comprende le informazioni aggiunte da te.
per aggiungere le informazioni devi fare:
$msg = $nome.' - '.$cognome. ' - '.$citta.' - '.$msg;e aggiungi questa riga prima di
mail($receiverMail, $subject, $msgformat, "From: $name <$email>");
-
Non funziona !!!!!
<?php
$receiverMail = "[email protected]";$nome = ltrim(rtrim(strip_tags(stripslashes($_POST['nome']))));
$cognome = ltrim(rtrim(strip_tags(stripslashes($_POST['cognome']))));
$città = ltrim(rtrim(strip_tags(stripslashes($_POST['citta']))));
$email = ltrim(rtrim(strip_tags(stripslashes($_POST['email']))));
$oggetto = ltrim(rtrim(strip_tags(stripslashes($_POST['oggetto']))));
$msg = ltrim(rtrim(strip_tags($_POST['msg'])));$ip = getenv("REMOTE_ADDR");
$msgformat = "From: $nome ($ip)\nEmail: $email\n\n$msg";// VALIDATION
if(empty($nome) || empty($cognome) || empty($citta) || empty($email) || empty($oggetto) || empty($msg)) {
echo "<h3>L'email non è stata inviata</h3><p>Riempite tutti i campi richiesti Grazie</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><p>The email address is invalid</p>";
}
else {
mail($receiverMail, $subject, $msgformat, "From: $name <$email>");
echo "<h3>The email has been sent!</h3><p>I will get back to you as soon as possible.</p>"; }
?>Tymba ho aggiunto la stringa
$msg = $nome.' - '.$cognome. ' - '.$citta.' - '.$msg; coma da te suggerita ma non è cambiato nulla.
A me non interessa questo form in particolare l'importante è che abbia i campi: Nome,Cognome,Città,Email,Oggetto e Messaggio
-
aiutatemi !!!
-
ehm.... credo la mia domanda sia banale, ma...
tu ci hai mandato il codice di invio.php, ma il form ha come action "contatti.php". non è forse quello?
e poi, un'altra curiosità... sei sicuro di aver settato correttamente il file php.ini per inviare le mail? lo dico solo perché io non sono mai riuscito!
-
Ripeto il formmail ha solo due file uno chiamato "contatti.php" e l'altro "invio.php"
contatti.php è questo
<form method="post" action="contatti.php">
<p>Nome:
<input name="nome" type="text" size="25" maxlength="40" />
Cognome:
<input name="cognome" type="text" size="25" maxlength="40" />
<br />
<br />
Città:
<input name="citta" type="text" id="citta" size="25" maxlength="40" />
Email:
<input name="email" type="text" size="25" maxlength="40" />
<br />
<br />
Oggetto:
<input name="oggetto" type="text" size="25" maxlength="40" />
</p>
<p> <br />
Messaggio:<br />
<textarea name="msg" cols="50" rows="6"></textarea>
<br />
<br />
<input type="reset" value="Cancella" />
<input type="submit" value="Invia" />
</p>
</form>invio.php è questo
<?php
$receiverMail = "[email protected]";$nome = ltrim(rtrim(strip_tags(stripslashes($_POST['nome']))));
$cognome = ltrim(rtrim(strip_tags(stripslashes($_POST['cognome']))));
$città = ltrim(rtrim(strip_tags(stripslashes($_POST['citta']))));
$email = ltrim(rtrim(strip_tags(stripslashes($_POST['email']))));
$oggetto = ltrim(rtrim(strip_tags(stripslashes($_POST['oggetto']))));
$msg = ltrim(rtrim(strip_tags($_POST['msg'])));$ip = getenv("REMOTE_ADDR");
$msgformat = "From: $nome ($ip)\nEmail: $email\n\n$msg";// VALIDATION
if(empty($nome) || empty($cognome) || empty($citta) || empty($email) || empty($oggetto) || empty($msg)) {
echo "<h3>L'email non è stata inviata</h3><p>Riempite tutti i campi richiesti Grazie</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><p>The email address is invalid</p>";
}
else {
mail($receiverMail, $subject, $msgformat, "From: $name <$email>");
echo "<h3>The email has been sent!</h3><p>I will get back to you as soon as possible.</p>"; }
?>Non esiste un file php.ini
-
metti come action nel form del file contatti.php "invio.php"!! altrimenti ti rimanda alla stessa pagina che contiene il form!
il file php.ini è quello che contiene vari settaggi del linguaggio... non è un file del tuo sito! devi verificare di aver inserito in quel file tutte le informazioni necessarie perché la funzione mail() possa funzionare.
-
Joe santiago sei grande era quello il problema "action" del form avevo sbagliato il file, l'avevo detto che ero una frana !!!
Grazie !!!
p.s.
hai un m.p.
-
figurati!
fosse stato un problema più complesso mica l'avrei saputo risolvere!