salve a tutti!
ho un problema con l'invio delle email con il form che ho creato per la rischiesta della password smarrita. allora, il form è questo:
Codice PHP:
<link rel="stylesheet" type="text/css" href="style.css" />
</HEAD>
<meta http-equiv="Content-type" value="text/html; charset=iso-8859-1rn" />
<BODY>
<center>
<base target="contenuto">
<form name="frm" action="send_password_ac.php" method="post" onSubmit="return validate()">
<table border="0" width="500">
<tr>
<td width="180"><div align="left">[img]http://images.findicons.com/files/icons/1722/gnome_2_18_icon_theme/24/mail_forward.png[/img][b]Inserisci indirizzo email:[/b]</td>
<td width="190"><input name="email_to" type="text" id="mail_to" size="30" class="recovery"></td>
</tr>
<tr>
<td width="180">
</td>
<td width="190"><button type="submit" class="password">Recupera password</button></td>
</tr>
<tr>
<td width="180"></td>
<td width="190"></td>
</tr>
</table>
</form>
<table width="502" border="0">
<tr>
<td><iframe src="http://naturewildlife.altervista.org/FORM_REGISTRAZIONE/password_dimenticata/white.html" width="600" height="50" frameborder="0" scrolling="no" name="contenuto" id="contenuto">
Your browser does not support iframes.</p>
</iframe></td>
</tr>
</table>
</div>
</center>
</BODY>
</HTML>
il form non è fatto benissimo ma va bene così
e adesso posto il codice in php del file che controlla l'invio della mail:
Codice PHP:
<?
$host="localhost"; // Host name
$username="*********"; // Mysql username
$password="**********"; // Mysql password
$db_name="**********"; // Database name
//Connect to server and select databse.
mysql_connect("$host", "$username", "$password")or die("cannot connect to server");
mysql_select_db("$db_name")or die("cannot select DB");
// value sent from form
$email_to=$_POST['email_to'];
// table name
$tbl_name=members;
// retrieve password from table where e-mail = $email_to(mark@phpeasystep.com)
$sql="SELECT password FROM $tbl_name WHERE email='$email_to'";
$result=mysql_query($sql);
// if found this e-mail address, row must be 1 row
// keep value in variable name "$count"
$count=mysql_num_rows($result);
// compare if $count =1 row
if($count==1){
$rows=mysql_fetch_array($result);
// keep password in $your_password
$your_password=$rows['password'];
// ---------------- SEND MAIL FORM ----------------
// send e-mail to ...
$to=$email_to;
// Your subject
$subject="NatureWildLife";
// From
$header="from: Richiesta password smarrita <your email>";
// Your message
$messages= "Salve utente! in questa email è presente la password da lei smarrita e che ha richiesto. \r\n";
$messages.="La sua password è: $your_password \r\n";
$messages.="\r\n";
// send email
$sentmail = mail($to,$subject,$messages,$header);
}
// else if $count not equal 1
else {
echo "<center><font face=\"arial\" color=\"red\" size=\"2\"><img src=\"http://images.findicons.com/files/icons/1686/led/16/cancel.png\" align=\"absmiddle\">Indirizzo email non trovato nel database.Impossibile inviare password.";
}
// if your email succesfully sent
if($sentmail){
echo "<center><font face=\"arial\" color=\"green\" size=\"2\"><img src=\"http://png.findicons.com/files/icons/1588/farm_fresh_web/16/tick.png\" align=\"absmiddle\">La password è stata inviata correttamente al tuo indirizzo email.</font></center>";
}
?>
il form verifica se l'indirizzo immesso nel campo è presente nel database, se è presente invia all'utente la sua password che ha dimenticato via email e il messaggio che dovrebbe esserci e questo:
Salve utente! in questa email è presente la password da lei smarrita e che ha richiesto.
la sua password è: [password].
però facendo delle prove nella email viene scritto:
Salve utente ! in questa email č presente la password da lei smarrita e che ha richiesto.
La sua password č: [password]
cpme posso fare per trasformare il messaggio della mail in formato html ??