Ir para conteúdo

Arquivado

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

iifabianoii

Erro na senha - codigo

Recommended Posts

Olá pessoal, desculpe está pedido a ajuda de vocês, mas ainda não consegui descobri o erro exatamente.

Tenho um sistema de cadastro no qual ao cadastrar está inserindo uma senha diferente da qual estou colocando no momento do cadastro, é como ela gera se uma senha automática, estilo essas de forum.

Vou deixar os arquivos do cadastro, e quem poder me ajudar, seria de grande ajuda.

 

index

 
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

<div class="conteudoregistro">
  <p><strong><?php
require('config.php');
if (!isset($_SESSION)) {
  session_start();
}
if($statistics == "on") {
 mysql_select_db(db, $con);
$login = mysql_query("SELECT * FROM login");
$char = mysql_query("SELECT * FROM `char`");
$account = mysql_num_rows($login);
$users = mysql_num_rows($char);
}
if($registration == "on") {
?>
<?php
$username = $_POST['username'];
$password = $_POST['pwd'];
$rp = $_POST['rp'];
$email = $_POST['email'];
$remail = $_POST['remail'];
$sex = $_POST['sex'];
$captcha = $_POST['captcha'];
$agree = $_POST['checkbox'];
$display = "display:none";
 if($username != NULL) { 
 mysql_select_db(db, $con);
$login = mysql_query("SELECT * FROM login where userid='$username'");
$rows = mysql_num_rows($login);
if($rows == "1") { $error .= "<li>".un."</li>"; }
if($email != $remail) { $error .= "<li>".rem."</li>";}
if($captcha != $_SESSION['security_code']) { $error .= "<li>".vin."</li>";}
if($password != NULL && $password != $rp) { $error .= "<li>".pep."</li>";}
if($error != NULL) { $display = ""; } else {
if($md5 == "on") $password = md5($password);
mysql_query("INSERT INTO login (userid, user_pass, sex, email)
VALUES ('$username', '$password', '$sex', '$email')");
echo "<center><div style='background: #72EE65; border: 1px solid green; width: 520px;'>".reg."</div></center>";
 }
 }
 ?>
<link rel="stylesheet" type="text/css" href="css/style.css" />
<script src="js/script.js"></script>
<script>
	function validateUsername(fld){var error="";var illegalChars=/\W/;if(fld.value==""){fld.style.background='Yellow';error="<li><?php echo ud; ?></li>";}else if((fld.value.length<<?php echo $userminlength?>)||(fld.value.length><?php echo $usermaxlength?>)){fld.style.background='Yellow';error="<li><?php echo ul; ?></li>";}else if(illegalChars.test(fld.value)){fld.style.background='Yellow';error="<li><?php echo ui; ?></li>";}else{fld.style.background='White';}
	return error;}
	function validateEmail(fld){var error="";var tfld=trim(fld.value);var emailFilter=/^[^@]+@[^@.]+\.[^@]*\w\w$/;var illegalChars=/[\(\)\<\>\,\;\:\\\"\[\]]/;if(fld.value==""){fld.style.background='Yellow';error="<li><?php echo ed; ?></li>";}else if(!emailFilter.test(tfld)){fld.style.background='Yellow';error="<li><?php echo el; ?></li>";}else if(fld.value.match(illegalChars)){fld.style.background='Yellow';error="<li><?php echo ei; ?></li>";}else{fld.style.background='White';}
	return error;}
	function revalidateEmail(fld){var error="";var email=document.getElementById('email').value;if(fld.value!=email){fld.style.background='Yellow';error="<li><?php echo rem; ?></li>";}else{fld.style.background='White';}
	return error;}
	function revalidatePassword(fld){var error="";var pass=document.getElementById('pwd').value;if(fld.value!=pass){fld.style.background='Yellow';error="<li><?php echo pem; ?></li>";}else{fld.style.background='White';}
	return error;}
	function validatePassword(fld){var error="";var illegalChars=/[\W_]/;if(fld.value==""){fld.style.background='Yellow';error="<li><?php echo pd; ?></li>";}else if((fld.value.length<<?php echo $passminlength?>)||(fld.value.length><?php echo $passmaxlength?>)){error="<li><?php echo pl; ?></li>";fld.style.background='Yellow';}else if(illegalChars.test(fld.value)){error="<li><?php echo pl; ?>.</li>";fld.style.background='Yellow';}else{fld.style.background='White';}
	return error;}
function validateRules(fld){var error="";var checked=fld.checked;if(checked!=true){fld.style.background='Yellow';error="<li><?php echo vrules; ?>.</li>";}else{fld.style.background='White';}
return error;}
function validateCaptcha(fld){var error="";var cap=fld.value;if(cap.length<5){fld.style.background='Yellow';document.getElementById('cdiv').style.background='Yellow';error="<li><?php echo vcap; ?>.</li>";}else{document.getElementById('cdiv').style.background='white';fld.style.background='White';}
return error;}
function check(){
var illegalChars=/\W/;
var username=document.getElementById('username').value;
var fld=document.getElementById('username');
if(illegalChars.test(fld.value)){fld.style.background='Yellow';alert("<?php echo ui; ?>");}else{fld.style.background='White';
if(username.length>1){
if(window.XMLHttpRequest)
{xmlhttp=new XMLHttpRequest();}
else
{xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");}
xmlhttp.onreadystatechange=function()
{if(xmlhttp.readyState==4&&xmlhttp.status==200)
{if(xmlhttp.responseText=="1"){document.getElementById('username').style.background="Yellow"; alert('<?php echo Already; ?>');}

else if((username.length<<?php echo $userminlength?>)||(username.length><?php echo $usermaxlength?>)){document.getElementById('username').style.background="Yellow"; alert('<?php echo ul; ?>');}else{document.getElementById('username').style.background="White";document.getElementById('checking').innerHTML='<img src="img/check.gif">';}}}
xmlhttp.open("GET","checkuser.php?name="+username,true);xmlhttp.send();}}
}
</script>
<script type="text/javascript">
 
var ClassName = "input"; // Note: Elements which you want to target have what class name???
var FocusColor = "#FF0000"; // What color do you want it to change to?
 
window.onload = function() {
    var inputfields = document.getElementsByTagName("input");
    for(var x = 0 ; x < inputfields.length ; x++ ) {
        if(inputfields[x].getAttribute("class") == ClassName) {
            inputfields[x].onfocus = function() {
                OriginalColor = this.style.border;
                this.style.border = "1px solid "+FocusColor;
            }
            inputfields[x].onblur = function() {
                this.style.border = OriginalColor;
            }
        }
    }   
}
</script>
<center>
<fieldset class="alert" id="alert" style="<?php echo $display; ?>"><?php echo $error; ?></fieldset>
<fieldset style="width: 500px;">
  <form name="register" onSubmit="return validateFormOnSubmit(this)" method="post">
  <div style="float:left; text-align:left; margin: 10px;">
<table>
<tr>
<td>
<label for="username"><?php echo Nick ?></label><br>
<input type="text" class="campo" name="username" id="username" class="input"  onKeyUp="recheck();">
</td><td valign="bottom"><div id="checking"><input type="button"  class="check" value="<?php echo Checar; ?>" onClick="check();"></div></td></tr><tr><td><div id="chuser"></div></td></tr><tr>
<td><label for="pwd"><?php echo Senha ?></label><br>
<input type="password" class="campo" name="pwd" id="pwd" class="input" onKeyDown="return disableCtrlKeyCombination(event);" onKeyPress="return disableCtrlKeyCombination(event);"></td>
<tr>
<td><label for="rp" class="campo"><?php echo "Re-Senha" ?></label><br>
<input type="password" class="campo" name="rp" id="rp" class="input" onKeyDown="return disableCtrlKeyCombination(event);" onKeyPress="return disableCtrlKeyCombination(event);"></td>
<tr>
<td><label for="email" class="campo"><?php echo Email ?></label><br>
<input type="text" class="campo" name="email" id="email" class="input" onKeyDown="return disableCtrlKeyCombination(event);" onKeyPress="return disableCtrlKeyCombination(event);"></td></tr>
<tr>
<td><label for="remail" class="campo"><?php echo "Re-Email" ?></label><br>
<input type="text" class="campo" name="remail" id="remail" class="input" onKeyDown="return disableCtrlKeyCombination(event);" onKeyPress="return disableCtrlKeyCombination(event);"></td>
</tr>
<tr>
<td><fieldset style="border: 1px solid #1683A9; padding: 3px;" class="campo"><legend><?php echo Sexo ?></legend>
<input type="radio" class="campo" name="sex" id="male" value="M" checked="checked"><label for="male"><?php echo Homem ?></label><input type="radio" class="campo" name="sex" value="F" id="female"><label for="female"><?php echo Mulher ?></label></fieldset></td>
</tr>
<tr>
<td>
<label for="captcha" class="campo"><?php echo Captcha ?></label><br>
<div style="height: 26px; width: 200px; border: 1px solid #1683A9;" class="campo" id="cdiv"><table width="200px;"><tr><td><input type="text" class="campo" name="captcha" id="captcha" style="height: 20px; width: 100px; border:0px"></td><td><span style="float:right"><img src="captcha.php" id="cimg"></span></td></tr></table></div></td><td valign="bottom"><div style="margin-bottom: 7px"><img src="img/refresh.gif" style="cursor:pointer;" onClick="return recaptcha('cimg')"></div></td>
</tr>
<tr>
<td>
<label for="checkbox" class="campo"><?php echo Regras ?></label> <input type="checkbox" id="checkbox"><br>
<div><input type="reset" class="submit" value="<?php echo Limpar; ?>" onClick="javascript:resets();"><input type="submit" value="<?php echo Enviar; ?>" class="submit"></div>
</td></tr>
</table>
</div><br>
</form>	
</fieldset>
<br>
<?php if($statistics == "on") {
echo '<div style="width: 525px; color: #ccc;">
- '.$servername.' -
<table width="100%"><tr><td width="50%"><div style="width: 98%; border: 1px solid #ccc; float:left;"><div style="padding: 10px">'.rm.': '.$account.'</div></div></td><td width="50%"><div style="width: 100%;  border: 1px solid #ccc; float:right;"><div style="padding: 10px">'.cc.': '.$users.'</div></div></td></tr></table>';
}
?>
</div>
</center>
<?php } else { 
 echo mainterance;
}
 ?></div>
	</div>
</body>
</html>

config.php

<?php

$statistics = "on"; // write in "" on or off
$registration = "on"; // write in "" on or off
$md5 = "on"; //if you using md5 encrypt you must write replace off with on
$userminlength = "4"; // Username Minimum Length, default is 4
$usermaxlength = "10"; // Username Maximum Length, default is 10
$passminlength = "6"; // Password Minimum Length, recomended is 6
$passmaxlength = "12"; // Password Maximum Length, recomended is 12
$servername = "nomeserver"; // You Ragnarok Server Name
/************************* Database ********************/
DEFINE(host, "localhost"); // database hostname default is localhost
DEFINE(user, "root"); // database username
DEFINE(pass, "senha"); // database password
DEFINE(db, "ragnarok");  // database
/*********************** Main *************************/
DEFINE(Username, "Username");
DEFINE(Password, "Password");
DEFINE(RePassword, "Re-Password");
DEFINE(Email, "Email Address");
DEFINE(Remail, "Re-Email Address");
DEFINE(Rules, "Accept rules");
DEFINE(Email, "Email");
DEFINE(Sex, "Sex");
DEFINE(Male, "Male");
DEFINE(Female, "Female");
DEFINE(captcha, "Captcha");
DEFINE(check, "Check");
DEFINE(reset, "Reset");
DEFINE(submit, "Register");
/********************* Statistics **********************/
DEFINE(rm, "Membros Registrados");
DEFINE(cc, "Personagens Criados");
/****************** Registration Errors *****************/
DEFINE(vrules, "Você tem que aceitar as regras para completar o registro!");
DEFINE(Already, "Nome '+document.getElementById('username').value+' Ja esta em uso, por favor, escolha outro!");
DEFINE(ud, "Você não escreveu o Nome.");
DEFINE(un, "Este Nome já está em uso");
DEFINE(ul, "O numero de caracteres do Nome é de ".$userminlength." a ".$usermaxlength."");
DEFINE(ui, "O nome contem caracteres ilegais.");
DEFINE(pd, "Você não colocou a senha.");
DEFINE(pl, "A senha tem que ter de ".$passminlength." á ".$passmaxlength." caracteres");
DEFINE(pi, "a senha contem caracteres ilegais.");
DEFINE(ed, "você não colocou o email.");
DEFINE(el, "email inválido");
DEFINE(ei, "Você não colocou o Nome.");
DEFINE(rem, "O email não combina, escreva corretamente");
DEFINE(pem, "A senha não combina, escreva corretamente");
DEFINE(vcap, "O captcha tem que ter 5 letras");
DEFINE(vin, "O Captcha está incorreto");
DEFINE(reg, "Pronto, agora você ".$username." Está regitrado, você já pode se logar<br>Boa sorte!");
/********************* Mainterance **********************/
DEFINE(mainterance, "Os Registros estão desabilitados temporariamente");
 $con = mysql_connect(host,user,pass);
?>

checkuser.php

<?php require_once('config.php');
$con = mysql_connect(host,user,pass);
mysql_select_db(db, $con);
$name = $_GET[name];
$login = mysql_query("SELECT * FROM login where userid='$name'");
$users = mysql_num_rows($login);
echo $users;
?>

captcha.php

<?php
session_start();

/*
* File: CaptchaSecurityImages.php
* Author: Simon Jarvis
* Copyright: 2006 Simon Jarvis
* Date: 03/08/06
* Updated: 07/02/07
* Requirements: PHP 4/5 with GD and FreeType libraries
* Link: http://www.white-hat-web-design.co.uk/articles/php-captcha.php
* 
* This program is free software; you can redistribute it and/or 
* modify it under the terms of the GNU General Public License 
* as published by the Free Software Foundation; either version 2 
* of the License, or (at your option) any later version.
* 
* This program is distributed in the hope that it will be useful, 
* but WITHOUT ANY WARRANTY; without even the implied warranty of 
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 
* GNU General Public License for more details: 
* http://www.gnu.org/licenses/gpl.html
*
*/

class CaptchaSecurityImages {

	var $font = 'abg.otf';

	function generateCode($characters) {
		/* list all possible characters, similar looking characters and vowels have been removed */
		$possible = '23456789bcdfghjkmnpqrstvwxyz';
		$code = '';
		$i = 0;
		while ($i < $characters) { 
			$code .= substr($possible, mt_rand(0, strlen($possible)-1), 1);
			$i++;
		}
		return $code;
	}

	function CaptchaSecurityImages($width='60',$height='25',$characters='6') {
		$code = $this->generateCode($characters);
		/* font size will be 75% of the image height */
		$font_size = $height * 0.80;
		$image = @imagecreate($width, $height) or die('Cannot initialize new GD image stream');
		/* set the colours */
		$background_color = imagecolorallocate($image, 255, 255, 255);
		$text_color = imagecolorallocate($image, 22, 131, 189);
		$text_color2 = imagecolorallocate($image, 0, 189, 82);
		$noise_color = imagecolorallocate($image, 255, 255, 255);
		/* generate random dots in background */
		for( $i=0; $i<($width*$height)/3; $i++ ) {
			imagefilledellipse($image, mt_rand(0,$width), mt_rand(0,$height), 1, 1, $noise_color);
		}
		/* generate random lines in background */
		for( $i=0; $i<($width*$height)/150; $i++ ) {
			imageline($image, mt_rand(0,$width), mt_rand(0,$height), mt_rand(0,$width), mt_rand(0,$height), $noise_color);
		}
		/* create textbox and add text */
		$textbox = imagettfbbox($font_size, 0, $this->font, $code) or die('Error in imagettfbbox function');
		$x = ($width - $textbox[4])/2;
		$y = ($height - $textbox[5])/2;
		imagettftext($image, $font_size, 0, 10, 16, $text_color, $this->font , $code) or die('Error in imagettftext function');
		/* output captcha image to browser */
		header('Content-Type: image/jpeg');
		imagejpeg($image);
		imagedestroy($image);
		$_SESSION['security_code'] = $code;
	}

}

$width = isset($_GET['width']) ? $_GET['width'] : '60';
$height = isset($_GET['height']) ? $_GET['height'] : '20';
$characters = isset($_GET['characters']) && $_GET['characters'] > 1 ? $_GET['characters'] : '5';

$captcha = new CaptchaSecurityImages($width,$height,$characters);

?>

Compartilhar este post


Link para o post
Compartilhar em outros sites

A senha que você está vendo no banco é diferente da digitada?

 

Não sei se foi você quem produziu esse código, mas ele está deixando a senha criptografada, o que é bom.

Compartilhar este post


Link para o post
Compartilhar em outros sites

A senha que você está vendo no banco é diferente da digitada?

 

Não sei se foi você quem produziu esse código, mas ele está deixando a senha criptografada, o que é bom.

 

 

sim, está diferente, mas quando tento logar com aquela conta diz que a senha está incorreta.

Compartilhar este post


Link para o post
Compartilhar em outros sites

Eu verifiquei que as senhas estão sendo passadas criptografadas com MD5, mas não tenho certeza se o sistema de login está criptografando a senha digitada pelo usuário antes de comparar com a senha atual do banco de dados. Se não estiver o login irá falhar mesmo.

Compartilhar este post


Link para o post
Compartilhar em outros sites

  • Conteúdo Similar

    • Por ILR master
      Fala galera.
      Espero que todos estejam bem.
      Seguinte: Tenho um arquivo xml onde alguns campos estão com : (dois pontos), como o exemplo abaixo:
       
      <item>
      <title>
      d sa dsad sad sadasdas
      </title>
      <link>
      dsadas dsa sad asd as dsada
      </link>
      <pubDate>sadasdasdsa as</pubDate>
      <dc:creator>
      d sad sad sa ad as das
      </dc:creator>
      </item>
       
      Meu código:
       
      $link = "noticias.xml"; 
      $xml = simplexml_load_file($link); 
      foreach($xml -> channel as $ite) {     
           $titulo = $ite -> item->title;
           $urltitulo = $ite -> item->link;
           print $urltitulo = $ite -> item->dc:creator;
      } //fim do foreach
      ?>
       
      Esse campo dc:creator eu não consigo ler. Como faço?
       
      Agradeço quem puder me ajudar.
       
      Abs
       
       
    • Por First
      Olá a todos!
       
      Eu estou criando um sistema do zero mas estou encontnrando algumas dificuldades e não estou sabendo resolver, então vim recorrer ajuda de vocês.
      Aqui está todo o meu código: https://github.com/PauloJagata/aprendizado/
       
      Eu fiz um sistema de rotas mas só mostra o conteúdo da '/' não sei porque, quando eu tento acessar o register nada muda.
      E eu também quero que se não estiver liberado na rota mostra o erro de 404, mas quando eu tento acessar um link inválido, nada acontece.
      Alguém pode me ajudar com isso? E se tiver algumas sugestão para melhoria do código também estou aceitando.
       
       
      Desde já, obrigado.
    • Por landerbadi
      Olá pessoal, boa tarde
       
      Tenho uma tabela chamada "produtos" com os seguintes campos (id, produto) e outra tabela chamada "itens" com os seguintes campos (id, prod_01, prod_02, prod_03, prod_04).
       
      Na tabela produtos eu tenho cadastrado os seguintes produtos: laranja, maçã, uva, goiaba, arroz, feijão, macarrão, etc.
       
      Na tabela itens eu tenho cadastrado os itens da seguinte maneira:
       
      1, laranja, uva, arroz, feijão;
      2, maçã, macarrão, goiaba, uva;
      3, arroz, feijão, maçã, azeite
       
      Meu problema é o seguinte: 
      Eu escolho um produto da tabela "produtos", por exemplo "uva".  Preciso fazer uma consulta na tabela "itens" para ser listado todos os registros que contenham o produto "uva" e que todos os demais produtos estejam cadastrados na tabela "produtos".
       
      No exemplo acima seria listado apenas dois registros, pois o terceiro registro não contém o produto "uva". 
       
      Alguém pode me ajudar? Pois estou quebrando a cabeça a vários dias e não consigo achar uma solução.
    • Por landerbadi
      Boa tarde pessoal. Estou tentado fazer uma consulta no banco de dados porém estou tendo dificuldades. Tenho uma tabela chamada "itens" com os seguintes campos: id, item, plural, ativo. Nela tem cadastrado vários itens e seu respectivo plural. No campo ativo eu coloco a letra "S" para informar que esta palavra está ativa no sistema. Por exemplo: 1, casa, casas, S 2, mesa, mesas, S 3, cama, camas, S 4, moto, motos, S 5, rádio, rádios O quinto registro "radio" não está ativo no sistema pois não tem um "S" no campo ativo. E outra tabela chamada "variações" com os seguintes campos (id, item1, item2, item3) com os seguintes registros: 1, casa, camas, moto 2, mesas, casas, radio 3, rádio, cama, mesa Eu preciso fazer uma busca na tabela variações da seguinte maneira: Eu escolho um registro na tabela "itens", por exemplo "casa". Preciso fazer com que o php me liste todos os registros da tabela "variações" que contenham a palavra "casa". Porém se tiver algum registro com a palavra "casas" também tem que ser listado. Neste caso ele irá encontrar dois registros. Agora eu preciso que o php verifique os demais itens e faça a listagem apenas dos item que estão ativos (que contenham um "S" no campo ativo. Neste caso ele irá encontrar apenas um registro, pois o segundo registro contém a palavra "rádio". E "rádio" não está ativo na tabela itens. Como faço isso?
    • Por First
      Olá a todos!
       
      Quando eu tento fazer o login me mostra esse erro "Could not log you in."; Alguém sabe me ajudar a resolver esse problema no meu código?
      <?php require_once("core/init.php"); if (Input::exists()) { if (Token::check(Input::get("token"))) { $validate = new Validate(); $validation = $validate->check($_POST, array( "username" => array("required" => true), "password" => array("required" => true) )); if ($validation->passed()) { $user = new User(); $remember = (Input::get("remember")) === "on" ? true : false; $login = $user->login(Input::get("username"), Input::get("password"), $remember); if ($login) { Session::flash("home", "Welcome back!"); Redirect::to("index.php"); } else { echo "Could not log you in."; } } else { foreach ($validation->errors() as $error) { echo $error."<BR>"; } } } } ?> <form action="" method="POST"> <div class="field"> <label for="username">Username</label> <input type="text" name="username" id="username"> </div> <div class="field"> <label for="password">Password</label> <input type="password" name="password" id="password"> </div> <div class="field"> <label for="remember"> <input type="checkbox" name="remember" id="remember"> Remember me </label> </div> <input type="hidden" name="token" value="<?php echo Token::generate(); ?>"> <input type="submit" value="Log in"> </form>  
       
      Desde já obrigado.
×

Informação importante

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