Ciao a tutti....allora sto realizzando un prog per la scuola...
il problema è questo...io ho un database chiamato utenti cosi fatto, id-username-password-email
ho realizzato il login per un sito internet...fino a qui tutto ok,il login funziona.
Dopo aver fatto il login l'utente x accede ad un form di prenotazione in cui inserisce nome-cognome-email-username(quello usato per la registrazione)-oggetto-testo con cui chiede di prenotare un campo da tennis.
Io vorrei che se l'username(che metto nel form di prenotazione) non fosse presente nel mio database utenti il sistema ti stampa un errore.
Ho fatto cosi:
$to = "anastasi.fr@tiscali.it";
// IL SOGGETTO DELLA MAIL
$subject = "Richiesta Prenotazione TENNIS CLUB";
// COSTRUZIONE DEL CORPO DEL MESSAGGIO
$body = "La richiesta di prenotazione contiene le seguenti informazioni: ". "\n";
$body .="Nome: " . trim(stripslashes($_POST["nome"])) . "\n";
$body .= "Cognome: " . trim(stripslashes($_POST["cognome"])) . "\n";
$body .= "Username: " . trim(stripslashes($_POST["user"])) . "\n";
$body .= "Oggetto: " . trim(stripslashes($_POST["oggetto"])) . "\n";
$body .= "testo: " . trim(stripslashes($_POST["testo"])) . "\n";
$body .= "mail: " . trim(stripslashes($_POST["mail"])) . "\n";
$verifica =$_POST["user"];
// INTESTAZIONI SUPPLEMENTARI
$headers = $_POST["mail"];
// INVIO DELLA MAIL SE UTENTE PRESENTE NEL DATABASE
$q = mysql_query("SELECT username FROM utenti WHERE user = '$verifica'");
if(@mail($to, $subject, $body, $headers)) { // SE L'INOLTRO E' ANDATO A BUON FINE...
echo "La mail è stata inoltrata con successo.";
} else {// ALTRIMENTI...
echo "Si sono verificati dei problemi nell'invio della mail.";
}
Ovviamente non funziona,il problema credo sia nella query...
qualcuno mi potrebbe aiutare,grazie in anticipo.