cuando la cambio y hago que tambien la incripte con el codigo 2 q esta mas abajo
lo sube bien a la base de datos pero cuando quiero iniciar sesion nose por que no la acepta :s alguien sabe cual es el problema?
Código PHP:
<?php
if($_POST[enviar]) {
require 'config.php' ;
function quitar($texto) {
$texto = trim($texto) ;
$texto = htmlspecialchars($texto) ;
$texto = str_replace(chr(160),'',$texto) ; # Elimina espacios que no pueden ser borrados por trim()
return $texto ;
}
$nick = quitar($_POST[nick]) ;
$email = quitar($_POST[email]) ;
$con = mysql_query("select count(id) from usuarios where nick='$nick' or email='$email'") ;
if(mysql_result($con,0,0)) {
echo 'El nick ya existe en la base de datos o ya está registrado el email. Haz click <a href="javascript:history.back(-1)">aquí</a> para regresar.' ;
}
else {
$imagen = "default.jpg";
$fecha = time() ;
$contrasena = md5(md5(quitar($_POST[contrasena]))) ;
$sexo = quitar($_POST[sexo]) ;
mysql_query("insert into usuarios (fecha,nick,contrasena,email,sexo,ip,imagen) values ('$fecha','$nick','$contrasena','$email','$sexo','$_SERVER[REMOTE_ADDR]','".$imagen."')") ;
echo 'Has sido registrad@ satisfactoriamente. Haz click <a href="index.php">aquí</a> para regresar a la página principal e iniciar sesión' ;
}
}
else {
?>
<script>
function revisar() {
if(formulario.nick.value.length < 3) {
alert('El nick debe contener por lo mínimo 3 caractéres.') ;
return false ;
}
if(formulario.contrasena.value.length < 6) {
alert('La contraseña debe contener por lo mínimo 6 caractéres.') ;
return false ;
}
if(formulario.contrasena.value != formulario.c_contrasena.value) {
alert('Las contraseñas no son correctas.') ;
return false ;
}
}
</script>
<form name="formulario" method="post" action="<?php echo $_SERVER["PHP_SELF"] ?>" onsubmit="return revisar()">
<b>Nick:</b><br>
<input type="text" name="nick" maxlength="20"><br>
<b>Contraseña:</b><br>
<input type="password" name="contrasena" maxlength="10"><br>
<b>Confirmar contraseña:</b><br>
<input type="password" name="c_contrasena" maxlength="10"><br>
<b>Email:</b><br>
<input type="text" name="email" maxlength="40"><br>
<b>Sexo:</b><br>
<select name="sexo">
<option value="0">Masculino
<option value="1">Femenino
</select><br><br>
<input type="submit" name="enviar" value="Registrar">
</form>
</div>
<?php
}
?>
este es el cambia la contraseña lo encontre por internet
2
Código PHP:
<?php
require("conexion.php");
require("funciones.php");
$idempresa = getParam($_GET["id"], "-1");
$action = getParam($_GET["action"], "");
if ($action == "edit") {
$idempresa = sqlValue($_POST["id"], "int");
$nombre = sqlValue(md5($_POST["contrasena"]), "text");
$direccion = sqlValue($_POST["direccion"], "text");
$telefono = sqlValue($_POST["telefono"], "text");
$sql = "UPDATE usuarios SET ";
$sql.= "contrasena=".$nombre.", email=".$direccion.", imagen=".$telefono." ";
$sql.= "WHERE id=".$idempresa;
mysql_query($sql, $conexion);
header("location: listado.php");
}
$sql = "SELECT * FROM usuarios WHERE id = ".sqlValue($idempresa, "int");
$queEmp = mysql_query($sql, $conexion);
$rsEmp = mysql_fetch_assoc($queEmp);
$total = mysql_num_rows($queEmp);
if ($total == 0) {
header("location: listado.php");
exit;
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>PHP con MySQL: Editar datos en MySQL</title>
<link href="styles.css" rel="stylesheet" type="text/css" />
</head>
<body>
<h3>Editar Empresa</h3>
<form method="post" id="frEmpresa" action="editar.php?action=edit">
<label for="nombre">nick</label>
<input type="text" id="contrasena" name="contrasena" value="<?php echo $rsEmp["contrasena"]; ?>" />
<br />
<label for="direccion">email</label>
<input type="text" id="direccion" name="direccion" value="<?php echo $rsEmp["email"]; ?>" />
<br />
<label for="telefono">Imagen</label>
<input type="text" id="telefono" name="telefono" value="<?php echo $rsEmp["imagen"]; ?>" />
<br />
<label for="bts"> </label>
<button type="submit">Guardar</button>
<button type="reset">Limpiar</button>
<input type="hidden" id="id" name="id" value="<?php echo $rsEmp["id"]; ?>" />
</form>
</body>
</html>