Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> [PHP]logowaie php/sql, pokazuje uzytkownika i hasło do bazy
navaga
post
Post #1





Grupa: Zarejestrowani
Postów: 20
Pomógł: 0
Dołączył: 1.01.2014

Ostrzeżenie: (0%)
-----


po uruchomieniu strony widoczny jest formularz logowania gdzie wypełnione jest już pole "użytkownik" root i "hasło"****. powinno być puste. Gdzie tego szukać struktura plików jest następująca: conexion.php, controlerlogin.php, crudusario.php, konto.php, error.php, index.php, registrarse.php i usuario.php
Go to the top of the page
+Quote Post
Pyton_000
post
Post #2





Grupa: Zarejestrowani
Postów: 8 068
Pomógł: 1414
Dołączył: 26.10.2005

Ostrzeżenie: (0%)
-----


autouzupełnianie przeglądarki?, wpisane w kodzie?... wróżkami nie jesteśmy...
Go to the top of the page
+Quote Post
navaga
post
Post #3





Grupa: Zarejestrowani
Postów: 20
Pomógł: 0
Dołączył: 1.01.2014

Ostrzeżenie: (0%)
-----


1.historia usunięta nic nie dało
2. baza śmiga na uzytkownika adam...
public static function conectar(){
$pdo_options[PDO::ATTR_ERRMODE]=PDO::ERRMODE_EXCEPTION;
self::$conexion=new PDO('mysql:host=localhost;dbname=baselogin','adam','383',$pdo_options);
return self::$conexion;
}
Go to the top of the page
+Quote Post
viking
post
Post #4





Grupa: Zarejestrowani
Postów: 6 380
Pomógł: 1116
Dołączył: 30.08.2006

Ostrzeżenie: (0%)
-----


Szukaj w formularzu <form> a nie wrzucasz losowy kod. Przejdź w tryb prywatny przeglądarki i zobacz efekt.


--------------------
Go to the top of the page
+Quote Post
navaga
post
Post #5





Grupa: Zarejestrowani
Postów: 20
Pomógł: 0
Dołączył: 1.01.2014

Ostrzeżenie: (0%)
-----


  1. <form class="w3-container" action="controller_login.php" method="post">
  2. <p>
  3. <label class="w3-label">
  4. Użytkownik
  5. </label>
  6. <input class="w3-input w3-border " type="text" name="usuario" >
  7. </p>
  8. <p>
  9. <label class="w3-label">Hasło</label>
  10. <input class="w3-input w3-border" type="password" name="pas">
  11. </p>
  12. <p>
  13. <input type="hidden" name="entrar" value="entrar">
  14. <button class="w3-btn w3-green">Zaloguj</button>
  15. </p>
  16. <p>Jeśli nie masz konta skontaktuj się z administratorem <a href="mailto:admin_buniespo@.com" target="_top">&#9993;</a></p>
  17. </form>



controlerlogin.php
  1. <?php
  2. require_once('usuario.php');
  3. require_once('crud_usuario.php');
  4. require_once('conexion.php');
  5.  
  6. //inicio de sesion
  7.  
  8. $usuario=new Usuario();
  9. $crud=new CrudUsuario();
  10. //verifica si la variable registrarse está definida
  11. //se da que está definicda cuando el usuario se loguea, ya que la envía en la petición
  12. if (isset($_POST['registrarse'])) {
  13. $usuario->setNombre($_POST['usuario']);
  14. $usuario->setClave($_POST['pas']);
  15. if ($crud->buscarUsuario($_POST['usuario'])) {
  16. $crud->insertar($usuario);
  17. header('Location: index.php');
  18. }else{
  19. header('Location: error.php?mensaje=El nombre de usuario ya existe');
  20. }
  21.  
  22. }elseif (isset($_POST['entrar'])) { //verifica si la variable entrar está definida
  23. $usuario=$crud->obtenerUsuario($_POST['usuario'],$_POST['pas']);
  24. // si el id del objeto retornado no es null, quiere decir que encontro un registro en la base
  25. if ($usuario->getId()!=NULL) {
  26. $_SESSION['usuario']=$usuario; //si el usuario se encuentra, crea la sesión de usuario
  27. header('Location: cuenta.php'); //envia a la página que simula la cuenta
  28. }else{
  29. header('Location: error.php?mensaje=Tus nombre de usuario o clave son incorrectos'); // cuando los datos son incorrectos envia a la página de error
  30. }
  31. }elseif(isset($_POST['salir'])){ // cuando presiona el botňn salir
  32. header('Location: index.php');
  33. unset($_SESSION['usuario']); //destruye la sesión
  34. }
  35. ?>
Go to the top of the page
+Quote Post
viking
post
Post #6





Grupa: Zarejestrowani
Postów: 6 380
Pomógł: 1116
Dołączył: 30.08.2006

Ostrzeżenie: (0%)
-----


Nie ma nic w tym kodzie co by uzupełniało te dane zatem najpewniej robi to przeglądarka. Ach te nieangielskie nazwy wszystkiego.


--------------------
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 22.08.2025 - 08:14