I have a form and I'm using a PHP file to write its content to a text file. My problem is that whenever I try to write special characters (such as è é à á ä etc...) they are replaced by other strange characters (such as è é Ã).
I have looked around but none of the solutions suggested on different forums solved my issue.
Here you can find the HTML form I'm talking about: http://beginninghtml.altervista.org/InfinitySMS_Web/index.html
The PHP file processing my html form is http://beginninghtml.altervista.org/InfinitySMS_Web/process-form-data.php
:
$phonenum = $_POST['phonenum'];
$messagetext = $_POST['messagetext'];
$types=$_POST['types'];
$message=stripslashes($messagetext);
//if no message entered and no mobile num entered print an error
if (empty($phonenum) && empty($messagetext)){
print "Non sono stati inseriti il testo del messaggio e il numero del destinatario.<br>Inseriscili per poter inviare il tuo messaggio.";
}
//if no message entered send print an error
elseif (empty($messagetext)){
print "Non è stato inserito alcun testo per il messaggio.<br>Inseriscilo per poter inviare il tuo messaggio.";
}
//if no mobile num entered send print an error
elseif (empty($phonenum)){
print "Non è stato inserito il numero del destinatario.<br>Inseriscilo per poter inviare il tuo messaggio.";
}
elseif (strlen($phonenum)<11){
if (strlen($phonenum)>9){
//if the form has both a phone number and a text message.
//write data to the file
$name = $_POST['phonenum'];
$email = $_POST['messagetext'];
$fp = fopen("formdata.txt", "a");
$savestring = $name . "!$@$!;" . $email . "!$@$!;\n";
fwrite($fp, $savestring);
fclose($fp);
header("location:success.html");
}
else
{
print "Il numero di cellulare inserito non è corretto: il numero del destinatario deve contenere 10 cifre.";
}
}
And here you are the URL to the txt file containing the so called "strange" characters: http://beginninghtml.altervista.org/InfinitySMS_Web/formdata.txt