acentuação não registra no formulário no banco de dados
ola´estou com um problema quando vou registrar algo no meu banco de dados ele nao envia os acentos tipo:
título, café, eles ficam assim > t?tulo, caf?...
segue abaixo os codigos
index.php
<?php
include 'DBConfig.php';
//Insert or Update contact information
if(isset($_POST['action_type']))
{
if ($_POST['action_type'] == 'add' or $_POST['action_type'] == 'edit')
{
//Sanitize the data and assign to variables
$id = mysqli_real_escape_string($link, strip_tags($_POST['ContactID']));
$Title = mysqli_real_escape_string($link, strip_tags($_POST['Title']));
$Category = mysqli_real_escape_string($link, strip_tags($_POST['Category']));
$Tags = mysqli_real_escape_string($link, strip_tags($_POST['Tags']));
$Image = mysqli_real_escape_string($link, strip_tags($_POST['Image']));
$Place = mysqli_real_escape_string($link, strip_tags($_POST['Place']));
$Number = mysqli_real_escape_string($link, strip_tags($_POST['Number']));
$County = mysqli_real_escape_string($link, strip_tags($_POST['County']));
$City = mysqli_real_escape_string($link, strip_tags($_POST['City']));
$State = mysqli_real_escape_string($link, strip_tags($_POST['State']));
$Phone = mysqli_real_escape_string($link, strip_tags($_POST['Phone']));
$Website = mysqli_real_escape_string($link, strip_tags($_POST['Website']));
if ($_POST['action_type'] == 'add')
{
$sql = "insert into academias set
titulo = '$Title',
categoria = '$Category',
tag = '$Tags',
imagem = '$Image',
local = '$Place',
numero = '$Number',
bairro = '$County',
cidade = '$City',
estado = '$State',
telefone = '$Phone',
site = '$Website'";
}else{
$sql = "update academias set
titulo = '$Title',
categoria = '$Category',
tag = '$Tags',
imagem = '$Image',
local = '$Place',
numero = '$Number',
bairro = '$County',
cidade = '$City',
estado = '$State',
telefone = '$Phone',
site = '$Website'
where id = $id";
}
if (!mysqli_query($link, $sql))
{
echo 'Error Saving Data. ' . mysqli_error($link);
exit();
}
}
header('Location: contactlist.php');
exit();
}
//End Insert or Update contact information
//Start of edit contact read
$gresult = ''; //declare global variable
if(isset($_POST["action"]) and $_POST["action"]=="edit"){
$id = (isset($_POST["ci"])? $_POST["ci"] : '');
$sql = "select id, titulo, categoria,
tag, imagem, local, numero, bairro, cidade, estado, telefone, site from academias
where id = $id";
$result = mysqli_query($link, $sql);
if(!$result)
{
echo mysqli_error($link);
exit();
}
$gresult = mysqli_fetch_array($result);
include 'update.php';
exit();
}//end of edit contact read
//Start Delete Contact
if(isset($_POST["action"]) and $_POST["action"]=="delete"){
$id = (isset($_POST["ci"])? $_POST["ci"] : '');
$sql = "delete from academias
where id = $id";
$result = mysqli_query($link, $sql);
if(!$result)
{
echo mysqli_error($link);
exit();
}
}//End Delete Contact
//Read contact information from database
$sql = "select id, titulo, categoria, tag, imagem, local, numero, bairro, cidade, estado, telefone, site from academias";
$result = mysqli_query($link, $sql);
if(!$result){
echo mysqli_error($link);
exit();
}
$contact_list = array();//Loo through each row on array and store the data to $contact_list[]
while($rows = mysqli_fetch_array($result))
{
$contact_list[] = array('id' => $rows['id'],
'titulo' => $rows['titulo'],
'categoria' => $rows['categoria'],
'tag' => $rows['tag'],
'imagem' => $rows['imagem'],
'local' => $rows['local'],
'numero' => $rows['numero'],
'bairro' => $rows['bairro'],
'cidade' => $rows['cidade'],
'estado' => $rows['estado'],
'telefone' => $rows['telefone'],
'site' => $rows['site']);
}
include 'contactlist.php';
exit();
?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="pt-br" xml:lang="pt-br">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>Loocalize - Academias</title>
<link href="style.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript">
function Validate(){
var valid = true;
var message = '';
var Title = document.getElementById("Title");
var Category = document.getElementById("Category");
if(Title.value.trim() == ''){
valid = false;
message = message + '* Titulo e Obrigatorio' + '\n';
}
if(Category.value.trim() == ''){
valid = false;
message = message + '* Categoria e Obrigatoria ';
}
if (valid == false){
alert(message);
return false;
}
}
function GotoHome(){
window.location = 'index.php?';
}
</script>
</head>
<body>
<div class="wrapper">
<div class="content" style="width: 500px !important;">
<p><img src="address-book.png"/></p>
<div>
<form id="frmContact" style="color:black" method="POST" action="index.php"
onSubmit="return Validate();" accept-charset="iso-8859-1,utf-8">
<input type="hidden" name="ContactID"
value="<?php echo (isset($gresult) ? $gresult["id"] : ''); ?>" />
<table>
<tr>
<td>
<label for="Title">Titulo: </label>
</td>
<td>
<input type="text" name="Title"
value="<?php echo (isset($gresult) ? $gresult["titulo"] : ''); ?>"
id="Title" class="txt-fld"/>
</td>
</tr>
<tr>
<td>
<label for="Category">Categoria: </label>
</td>
<td>
<input type="text" name="Category"
value="<?php echo (isset($gresult) ? $gresult["categoria"] : ''); ?>"
id="Category" class="txt-fld"/>
</td>
</tr>
<tr>
<td>
<label for="Tags">TAG: </label>
</td>
<td>
<input type="text" name="Tags"
value="<?php echo (isset($gresult) ? $gresult["tag"] : ''); ?>"
class="txt-fld"/>
</td>
</tr>
<tr>
<td>
<label for="Image">Imagem: </label>
</td>
<td>
<input type="text" name="Image"
value="<?php echo (isset($gresult) ? $gresult["imagem"] : ''); ?>"
class="txt-fld"/>
</td>
</tr>
<tr>
<td>
<label for="Place">Local: </label>
</td>
<td>
<input type="text" name="Place"
value="<?php echo (isset($gresult) ? $gresult["local"] : ''); ?>"
class="txt-fld"/>
</td>
</tr>
<tr>
<td>
<label for="Number">Numero: </label>
</td>
<td>
<input type="text" name="Number"
value="<?php echo (isset($gresult) ? $gresult["numero"] : '');?>"
class="txt-fld"/>
</td>
</tr>
<tr>
<td>
<label for="County">Bairro: </label>
</td>
<td>
<input type="text" name="County"
value="<?php echo (isset($gresult) ? $gresult["bairro"] : '');?>"
class="txt-fld"/>
</td>
</tr>
<tr>
<td>
<label for="City">Cidade: </label>
</td>
<td>
<input type="text" name="City"
value="<?php echo (isset($gresult) ? $gresult["cidade"] : '');?>"
class="txt-fld"/>
</td>
</tr>
<tr>
<td>
<label for="State">Estado: </label>
</td>
<td>
<input type="text" name="State"
value="<?php echo (isset($gresult) ? $gresult["estado"] : '');?>"
class="txt-fld"/>
</td>
</tr>
<tr>
<td>
<label for="Phone">Telefone: </label>
</td>
<td>
<input type="text" name="Phone"
value="<?php echo (isset($gresult) ? $gresult["telefone"] : '');?>"
class="txt-fld"/>
</td>
</tr>
<tr>
<td>
<label for="Website">Site: </label>
</td>
<td>
<input type="text" name="Website"
value="<?php echo (isset($gresult) ? $gresult["site"] : '');?>"
class="txt-fld"/>
</td>
</tr>
</table>
<input type="hidden" name="action_type" value="<?php echo (isset($gresult) ? 'edit' : 'add');?>"/>
<div style="text-align: center; padding-top: 30px;">
<input class="btn" type="submit" name="save" id="save" value="Salvar" />
<input class="btn" type="submit" name="save" id="cancel" value="Cancelar"
onclick=" return GotoHome();"/>
</div>
</form>
</div>
</div>
</div>
</body>
</html>Discussão (4)
Carregando comentários...