Ir para conteúdo

POWERED BY:

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

visitante_php

[Resolvido] caracteres nao filtrado

Recommended Posts

esse script eh de uma enquete que eu peguei na internet, e foi adaptada, e mesmo assim, ela esta cadastrando dados com acentos, indo com acento pro banco, esta aparecendo caracteres indesejaveis na pagina, ja tentei usar o htmlspecislchars e nada... =/

(pq normalmente o form ja deixa o acento em caractere html no banco, mas nao eh isso q esta ocorrendo)

<?
/* Admin tool for the Ajax poller script */

error_reporting(E_ALL);
ini_set('error_reporting', E_ALL);
ini_set("display_errors", "1");

include_once("dbConnect.php");
include_once("classes/poll.class.inc");


?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
	<title>Administração de enquete</title>
	<link rel="stylesheet" href="css/admin.css" type="text/css">
	<script type="text/javascript">
	function moveDown(optionId)
	{
		var el = document.getElementById('option' + optionId);
		if(el.nextSibling){
			var nextObj = el.nextSibling;
			var inputsNext = nextObj.getElementsByTagName('INPUT');
			
			var nextOrder = false;
			for(var no=0;no<inputsNext.length;no++){
				if(inputsNext[no].id.indexOf('existing_pollOrder')>=0)nextOrder = inputsNext[no];	
			}
			var inputsThis = el.getElementsByTagName('INPUT');
			var thisOrder = false;
			for(var no=0;no<inputsThis.length;no++){
				if(inputsThis[no].id.indexOf('existing_pollOrder')>=0)thisOrder = inputsThis[no];	
			}			
			var tmpValue = nextOrder.value;
			nextOrder.value = thisOrder.value;
			thisOrder.value = tmpValue;
			el.parentNode.insertBefore(el.nextSibling,el);
		}
		
	}
	</script>
	
</head>
<body><table width="100%" border="1">
  <tr>
	<td> </td>
	<td> </td>
	<td> </td>
  </tr>
  <tr>
	<td> </td>
	<td> </td>
	<td> </td>
  </tr>
  <tr>
	<td> </td>
	<td>
<form action="<? echo $_SERVER['PHP_SELF']; ?>" method="post">
<?

$id = "";
if(isset($_POST['ID']))$id = $_POST['ID'];	// Opened by form submission
if(isset($_GET['id']))$id = $_GET['id'];	// Opened from list
if(isset($_POST['cancel']))$id = "";

if(isset($_POST['delete'])){
	$pollObj = new poll();
	$pollObj->deletePoll($_POST['ID']);	
	
}

if(isset($_POST['save'])){
	$pollObj = new poll();
	
	if(empty($_POST['ID'])){ // new poll
		if(isset($_POST['pollerTitle'])){
			$id = $pollObj->createNewPoller($_POST['pollerTitle']);
			echo "ID: ".$id;
			for($no=0;$no<count($_POST['pollOption']);$no++){
				if(!empty($_POST['pollOption'][$no])){
					$pollObj->addPollerOption($_POST['pollOption'][$no],$no);	
				}	
			}
			

			
		}else{
			$error_message = "Procurando o titulo da enquete";
		}
	}else{	// Update existing poll
		$pollObj->setId($_POST['ID']);	// Setting id
		if(isset($_POST['pollerTitle']))$pollObj->setPollerTitle($_POST['pollerTitle']);
		foreach($_POST['existing_pollOption'] as $key=>$value){
			if(!empty($_POST['existing_pollOption'][$key]))	$pollObj->setOptionData($_POST['existing_pollOption'][$key],$_POST['existing_pollOrder'][$key],$key);
		}
		
		$maxOrder = $pollObj->getMaxOptionOrder() + 1;
		for($no=0;$no<count($_POST['pollOption']);$no++){
			if(!empty($_POST['pollOption'][$no])){
				$pollObj->addPollerOption($_POST['pollOption'][$no],$maxOrder);	
				$maxOrder++;
			}	
		}
					
	}
		
	
	
	
}

// Show a list of all the polls
if(!isset($_POST['new']) && empty($id)){
	?>
	<fieldset>
		<table>
			<tr>
				<td><input type="submit" name="new" value="Nova" class="formButton"></td>
			</tr>
		</table>
	</fieldset>	
	<fieldset>
		<legend>Todas as enquetes</legend>
		<table>
		<?	
		$res = mysql_query("select * from poller order by pollerTitle");
		while($inf = mysql_fetch_array($res)){
			echo "<tr><td><a href=\"".$_SERVER['PHP_SELF']."?id=".$inf["ID"]."\">".$inf["pollerTitle"]."</a></td></tr>";
		}
		?>
		</table>
	</fieldset>
	<?
}


/***
* Show a new poll or edit a poll
***/

if(isset($_POST['new']) || !empty($id))
{

	$pollObj = new poll();
	if(!empty($id)){
		$pollObj->getDataById($id);		
		$pollerOptions = $pollObj->getOptionsAsArray();
		$votes = $pollObj->getVotesAsArray();
	}else{
		$pollerOptions = array();
		$votes = array();
	}

	
	?>
	
	<input type="hidden" name="ID" value="<? echo $pollObj->ID; ?>">
	<fieldset>
		<table>
			<tr>
				<td><input type="submit" name="save" value="Gravar" class="formButton"></td>
				<td><input type="submit" name="cancel" value="Cancelar" class="formButton"></td>
				<?
				if(!empty($id)){
					?>
					<td><input type="submit" name="delete" value="Apagar" onclick="return confirm('Clique em OK para apagar esta enquete')" class="formButton"></td>
					<?					
				}
				?>
			</tr>
		</table>
	</fieldset>
	<fieldset>
		<legend>Criar/Editar enquete</legend>
		<table>
			<tr>
				<td><label for="pollerTitle">Título da enquete(pergunta)</label></td>
				<td><input type="text" size="60" maxlength="55" id="pollerTitle" name="pollerTitle" value="<? echo $pollObj->pollerTitle; ?>"></td>
			</tr>
		</table>
		<table width="100%">
			<tr>
				
				<?
				if(!isset($_POST['new'])){
					?>
					<th>Opção</th>
			  <th>Votos</th>
					<th>Mover para baixo</th>
					<?
				}else{
					?>
					<th>Opções</th>
					<?
				}
				?>
			</tr>
			<?
			foreach($pollerOptions as $key=>$value){
				//echo "?><tr id="option<?php echo $key;?>"><!--";-->
				<!--echo "*/--><td><input type="text" maxlength="255" size="50" name="existing_pollOption[<?php echo $key; ?>]" value="<?php echo $pollerOptions[$key][0];?>"></td><!-- ";-->
				<!--echo "--><td><!--".--><?php echo isset($votes[$key])?$votes[$key]:0;?></td><!--";-->
				<!--echo "--><input type="hidden" id="existing_pollOrder[<?php echo $key;?>]" name="existing_pollOrder[<?php echo $key?>]" value="<?php echo $pollerOptions[$key][1];?>"><!--";-->
				<!--echo "--><td><a href="#" onclick="moveDown('<?php echo $key; ?>');return false">Mover</a></td><!--";-->
				<!--echo "--></tr><!--\n";-->				
		<?php	}
			
			if(empty($id)){
				$countInputs = 10;		
			}else{
				$countInputs = 3;
				//echo "?><tr><td><b>Novas opções</td></tr><!--";-->
			<?php	 
			}
			for($no=0;$no<$countInputs;$no++){ //echo " ?>
				<tr><td><input type="text" maxlength="255" size="50" name=" pollOption[<?php echo $no; ?>]\"></td></tr><!--\n";-->					
			<?php }	
				
			?>							
		</table>		
	</fieldset>	
	
	<?	
}

?>
</form></td>
	<td> </td>
  </tr>
  <tr>
	<td> </td>
	<td> </td>
	<td> </td>
  </tr>
  <tr>
	<td> </td>
	<td> </td>
	<td> </td>
  </tr>
</table>
</body>
</html>

Compartilhar este post


Link para o post
Compartilhar em outros sites

×

Informação importante

Ao usar o fórum, você concorda com nossos Termos e condições.