I've a problem with storing my data into an XML file:
I am using a PHP script that receives data from user via mobile app and inserts it into an XML file. But if the user inserts arabic words (name-password-...etc), it's stored as question marks in the XML file.
Hint: I already set the XML encoding = UTF8.
Here's my code :
<html>
<head></head>
<form action="sign.php" method="post">
name :<input type="text" name="name"/><br />
pass :<input type="text" name="pass"/><br />
mob :<input type="text" name="mobile"/><br />
mail :<input type="text" name="email"/><br />
<input type="submit" name="send" value="send"/>
</form>
</html>
<?php
header('Content-Type: text/html; charset=Windows-1256');
$test = utf8_encode("ياسمين");
echo mb_detect_encoding($test);
echo $test;
if(isset($_POST['send'])){
if(isset($_POST['name']) && isset($_POST['pass']) && isset($_POST['mobile']) &&isset($_POST['email'])) {
$name = $_POST['name'];
$pass = $_POST['pass'];
$mob = $_POST['mobile'];
$mail = $_POST['email'];
$xml = simplexml_load_file('mowasla.xml');
$user = $xml->users->addChild('user');
$user->addChild('user_name', $name);
$user->addChild('pass', $pass);
$user->addChild('phone', $mob);
$user->addChild('email', $mail);
file_put_contents('mowasla.xml', $xml->asXML());
echo("done");
echo ($name);
}else{
echo("error");
die;
}
}
?>