Ver Mensaje Individual
  #13 (permalink)  
Antiguo 24/09/2008, 09:16
Avatar de chitoso
chitoso
 
Fecha de Ingreso: mayo-2008
Ubicación: Montevideo, Uruguay
Mensajes: 205
Antigüedad: 16 años
Puntos: 5
Respuesta: Es suficiente con AddSlashes() para evitar la inyección SQL?

Te dejo la url del manual PHP y un código de muestra que uso en una de mis apps.


PHP: PDO

Código php:
Ver original
  1. ...            
  2.        
  3. $stmt = $link->prepare("INSERT INTO administrators(id, username, password, email, phone, type)
  4. VALUES (:id, :username, :password, :email, :phone, :type)");
  5.            
  6. $stmt->bindParam(':id', $new_id);
  7. $stmt->bindParam(':username', $p_admin->getUsername());
  8. $stmt->bindParam(':password', $p_admin->getPassword());
  9. $stmt->bindParam(':email', $p_admin->getEmail());
  10. $stmt->bindParam(':phone', $p_admin->getPhone());
  11. $stmt->bindParam(':type', $p_admin->getType());
  12.  
  13. try{
  14.     $stmt->execute();
  15. }
  16. catch(PDOException $e){
  17.     throw new Exception($e->getMessage());
  18. }
  19. ...
__________________
Pasión por la Música