我无法在我用来学习编码的网页上显示ñ。
mysql数据库有latin1_spanish_ci整理。我尝试使用解码(utf-8)将排序设置为utf-8,将页面字符集设置为charset = ISO-8859-1,但似乎没有任何效果。
这是php代码
的index.php
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<title>
Bitácora
</title>
</head>
<body>
<?php require_once('db_conn.php');?>
<?php require_once('script.php');?>
<?php if($_COOKIE['username'] === NULL){
header("Location: login.php");
} else {
//
}
?>
<div>
<p>Estás logueado como " <?php echo ucwords(strtolower($row['nombre'])) . " " . ucwords(strtolower($row['apellido'])); ?>"</p>
</div>
<form action="inserta.php" id="formaLog" name="formaLog" method="POST">
<textarea style="overflow:auto;resize:none" rows="4" cols="80" id="log" name="log" required></textarea>
<input type="submit" name="envia" value="Enviar" id="envia" />
</form>
<br />
<?php require_once('menu.php'); ?>
</body>
</html>
的script.php
<?php
require_once('db_conn.php');
$dbc = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);
if( isset($_COOKIE['user_id']) ){
// mysqli_set_charset($dbc,"utf8");
// Look up the username and password in the database
$username = $_COOKIE['username'];
$id = $_COOKIE['user_id'];
$query = "SELECT id, username, nombre, apellido FROM usuarios WHERE username = '$username'";
$data = mysqli_query($dbc, $query);
if (mysqli_num_rows($data) == 1) {
// The log-in is OK so set the user ID and username cookies, and redirect to the home page
$row = mysqli_fetch_array($data);
}
}
?>