【发布时间】:2015-09-01 15:05:38
【问题描述】:
我无法在我网站上的表单中使用瑞典语字符。如果我使用 ÅÄÖ,该网站只会显示错误消息“所有字段都需要填写”。
如果我只输入 oaa 左右,它适用于所有字段,但如果我在其中一个字段中使用 ÅÄÖ,我会收到需要填写所有字段的错误。
这对我来说是个问题,因为我在网络上有一个瑞典广播电台,而我的听众想用瑞典语向我发送请求。
谁能帮助我,或者我该如何解决这个问题?
<?php
// Include the required glob.php file
require_once( "../_inc/glob.php" );
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>radiPanel: Review Our DJ</title>
<style type="text/css" media="screen">
body {
background: #ddeef6;
padding: 0;
margin: 0;
}
body, a, input, select, textarea {
font-family: Verdana, Tahoma, Arial;
font-size: 11px;
color: #333;
text-decoration: none;
}
a:hover {
text-decoration: underline;
}
form {
padding: 0;
margin: 0;
}
.wrapper {
background-color: #fcfcfc;
width: 350px;
margin: auto;
padding: 5px;
margin-top: 15px;
}
.title {
padding: 5px;
margin-bottom: 5px;
font-size: 14px;
font-weight: bold;
background-color: #eee;
color: #444;
}
.content {
padding: 5px;
}
.good, .bad {
padding: 5px;
margin-bottom: 5px;
}
.good strong, .bad strong {
font-size: 12px;
font-weight: bold;
}
.good {
background-color: #d9ffcf;
border-color: #ade5a3;
color: #1b801b;
}
.bad {
background-color: #ffcfcf;
border-color: #e5a3a3;
color: #801b1b;
}
input, select, textarea {
border: 1px #e0e0e0 solid;
border-bottom-width: 2px;
padding: 3px;
}
input {
width: 170px;
}
input.button {
width: auto;
cursor: pointer;
background: #eee;
}
select {
width: 176px;
}
textarea {
width: 288px;
}
label {
display: block;
padding: 3px;
}
</style>
</head>
<body>
<div class="wrapper">
<div class="title">
Bedöm en DJ
</div>
<div class="content">
<?php
// Check if the form has been submitted
if( $_POST['submit'] ) {
// The form has been submitted
try {
// Right, we have their data, so we check it and clean it up
$habbo = $core->clean( $_POST['habbo'] );
$dj = $core->clean( $_POST['dj'] );
$review = $core->clean( $_POST['review'] );
$ip = $_SERVER['REMOTE_ADDR'];
$time = time();
// Check for blank fields
if ( !$habbo or !is_numeric( $dj) or !$review ) {
// They have a problem
throw new Exception( "Alla fält är nödvändiga!" );
}
else {
// Everything is fine, so now to add our cleaned data to the database!
$db->query( "INSERT INTO reviews VALUES (NULL, '{$habbo}', '{$dj}', '{$review}', '{$ip}', '{$time}');" );
echo "<div class=\"good\">";
echo "<strong>Klart!</strong>";
echo "<br />";
echo "Din bedömning har nu skickats in, tack så mycket!";
echo "</div>";
}
}
catch( Exception $e ) {
echo "<div class=\"bad\">";
echo "<strong>Error</strong>";
echo "<br />";
echo $e->getMessage();
echo "</div>";
}
}
?>
<p><strong>Känner du att du vill ge lite ris och ros till någon av våra DJ's?</strong> Använd formuläret nedanför och gör en bedömning på någon av våra DJ's!</p>
<form action="" method="post">
<label for="habbo">Ditt namn:</label>
<input type="text" name="habbo" id="habbo" maxlength="255" />
<br /><br />
<label for="dj">DJ:</label>
<select name="dj" id="dj">
<?php
$users = $db->query( "SELECT * FROM users" );
while( $array = $db->assoc( $users ) ) {
?>
<option value="<?php echo $array['id']; ?>">
DJ <?php echo $array['username']; ?>
</option>
<?php
}
?>
</select>
<br /><br />
<label for="review">Meddelande:</label>
<textarea name="review" id="review" rows="10"></textarea>
<br /><br />
<input class="button" type="submit" name="submit" value="Skicka" />
</form>
</div>
</div>
</body>
</html>
There you have some code..
【问题讨论】:
-
您需要以 UTF-8 编码您的页面。在 Google 上进行快速搜索应该会为您提供所需的信息。
-
我有,因为我的网站显示 ÅÄÖ 但如果您填写表格时使用 åäö 就会出错