Check out the response of
var_dump ($nome)
var_dump ($arrayReturn['nome'])
And the logic is the same
if( $nome <> $arrayReturn['nome']){
echo "Erro!";
exit();
}
If I understand correctly, the return of $arrayReturn['name'] should be something like: Stack Overflow and the $name stack-overflow
Am I right? Then add the function:
<?php
/***
* Função para remover acentos de uma string
*
* @autor Thiago Belem <[email protected]>
*/
function removeAcentos($string, $slug = false) {
$string = strtolower($string);
// Código ASCII das vogais
$ascii['a'] = range(224, 230);
$ascii['e'] = range(232, 235);
$ascii['i'] = range(236, 239);
$ascii['o'] = array_merge(range(242, 246), array(240, 248));
$ascii['u'] = range(249, 252);
// Código ASCII dos outros caracteres
$ascii['b'] = array(223);
$ascii['c'] = array(231);
$ascii['d'] = array(208);
$ascii['n'] = array(241);
$ascii['y'] = array(253, 255);
foreach ($ascii as $key=>$item) {
$acentos = '';
foreach ($item AS $codigo) $acentos .= chr($codigo);
$troca[$key] = '/['.$acentos.']/i';
}
$string = preg_replace(array_values($troca), array_keys($troca), $string);
// Slug?
if ($slug) {
// Troca tudo que não for letra ou número por um caractere ($slug)
$string = preg_replace('/[^a-z0-9]/i', $slug, $string);
// Tira os caracteres ($slug) repetidos
$string = preg_replace('/' . $slug . '{2,}/i', $slug, $string);
$string = trim($string, $slug);
}
return $string;
}
And change to:
if( $nome <> str_replace(" ","-",removerosAcentos($arrayReturn['nome'])) ){
echo "Erro!";
exit();
}
The variable
$nome
is of the correct value? Of avar_dump
and checks– Costamilam
Actually, the answer was NULL. I added: $name = @$_POST['name']. @$_GET['name']; and it worked.
– J. Doe
@Guilhermecostamilam, I made a modification to the question.
– J. Doe