i는 사용자 등록 클래스를 정의하기 위해 노력하고있어이는 내가에 allways없이있는 양식을 통해 간단한 VARCHAR를 입력이 오류를 (주어진거야 것을의 지금이 쿼리에 어떤 문제가 있습니까?
<?php
///// SE SUPONE QUE AQUI EL USUARIO YA HA INTRODUCIDO SUS DATOS DE REGISTRO
/* Conectando la Base de Datos */
include("includes/basedatos.php");
require_once("includes/funciones.php");
class registro_usuarios
{
var $pass;
var $email;
var $nombre;
public function tratandovariables()
{
/* Eliminando Caracteres Especiales */
$password = htmlspecialchars($_POST['pass']);
$mail = htmlspecialchars(strip_tags($_POST['mail']));
$nombre = htmlspecialchars(strip_tags($_POST['nombre']));
if (preg_match("/^[a-zA-Z0-9\-_]{3,20}$/", $nombre))
{
/* Asignando Valor */
$this->pass = md5($password);
$this->email = $mail;
$this->nombre = $nombre;
}
else
{
echo "El nombre de usuario no es válido<br>";
exit;
}
}
public function register()
{
$this->tratandovariables();
/* Comprobando si existe el usuario */
$check = "SELECT * FROM usuarios WHERE alias = '$this->nombre'";
$qry = mysql_query($check);
/* La compracion */
if (mysql_num_rows($qry))
{
echo "Lo sentimos, el nombre de usuario ya esta registrado.<br />";
mysql_free_result($qry);
return false;
} else
{
$insert = "INSERT INTO usuarios (alias, pass, email, fid, fechar, ultima, img_src, reputacion) VALUES ('".$this->nombre."','".$this->pass."','".$this->email."','-1', 'NOW()', 'NOW()',' ', '0')";
$qry = mysql_query($insert);
if(mysql_affected_rows())
{
echo "El Usuario $this->nombre se Registro Correctamente";
return true;
}
else
{
echo "Error Ingresando datos";
return false;
}
return false;
}
}
}
?>
에 대해 가지고있는 기능과 문제 이상한 문자) :
경고 :로 MYSQL_ASSOC() : 공급 인수가 52 엘 사용자 선호도 토니가 Registro을 SE는 라인에 /home/piscolab/public_html/keepyourlinks.com/Recetas/registro.php에 유효한 MySQL의 결과 리소스 아니다 정답
- $ this-> nombre에 null 값이 없습니다 (선택됨)
- 데이터베이스가 비어 있으므로 결과가 없어야합니다.
- 문제는 스크립트가 계속 실행되어 사용자가 등록되었다고 가정하고 이름을 표시하는 것입니다. 데이터베이스에 대한 업데이트가 없습니다.
난 그냥 문제를 볼 수 없다 .. 할 수 있을까요?
감사합니다. 여기
registro.php에서 52 행을 게시 할 수 있습니까? 여기에 mysql_fetch_array가 없다. 사실, 당신이 쿼리를 실행 51 줄을 게시하십시오. 정확한 쿼리를 보여줍니다. 또한 mysql_query() 함수 뒤에 "die (mysql_error())"를 추가하여 쿼리에 오류 (예 : 잘못된 테이블 이름)가 있는지 확인할 수 있습니다. – Tjirp
와우, 당신은 [SQL Injection] (http://en.wikipedia.org/wiki/SQL_injection) 공격에 대해 광범위하게 개방되어 있음을 알아야합니다, 맞습니까? 입력을 이스케이프하거나 (mysql_real_escape_string을 통해) 또는 매개 변수화 된 쿼리를 사용하십시오 (더 나은 대안) ... – ircmaxell
MySQL은 영어 만 사용합니다. cheap_humor> – mattbasta