Ver Mensaje Individual
  #1 (permalink)  
Antiguo 31/10/2014, 17:25
joseantoniogf1
 
Fecha de Ingreso: mayo-2014
Mensajes: 13
Antigüedad: 10 años
Puntos: 0
sistema login

hola a todos,

necesito que me corrijáis mi sistema de logueo, cuando pincho a enviar lo unico que me hace es recargar la propia pagina. en la pestaña contactar es donde tengo el formlario para introducir los datos.


os dejo los documentos.

portada.php

Código PHP:
Ver original
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta http-equiv="content-type" content="text/html; charset=UTF8">
  5. <title>CASA DE PERROS</title>
  6. <LINK REL="stylesheet" TYPE="text/css" HREF="cssportada.css">
  7.  
  8. <script>
  9.     window.onload=function(){
  10.         document.getElementById("sitio").onclick=function (){mostrar(this);};
  11.         document.getElementById("conocenos").onclick=function (){mostrar(this);};
  12.         document.getElementById("Adopta").onclick=function (){mostrar(this);};
  13.         document.getElementById("abandona").onclick=function (){mostrar(this);};
  14.    
  15.     }
  16.    
  17.     function mostrar(menu){
  18.                 objCaja=document.getElementById("caja");
  19.         switch (menu.id){
  20.         case "sitio":
  21.            
  22.         break;
  23.         case "conocenos":
  24.            
  25.            
  26.         break;
  27.         case "Adopta":
  28.            
  29.         break;
  30.         case "abandona":
  31.            
  32.         objCaja.innerHTML = "<div id='texto3'><h2>¿NO PUEDE HACERSE CARGO DE SU PERRO?</h2></br></br></br>Para rellenar el formulario <a href='formularioperrospendiente.html'><u>PINCHA AQUÍ</u></a></br></br></div>";
  33.             objCaja.innerHTML +="<div id='login' align='right'></br><b>Iniciar Sesión</b></br></br><form name='form1' method='post' action='entrar2.php'>Username:&nbsp;&nbsp;<input type='text' placeholder='Correo electronico...' name='username'/></br></br>Password:&nbsp;&nbsp;<input type='text' placeholder='Clave de acceso...' name='password'/></br></br><INPUT name='submit' type='submit' value='Enviar'></form><\div>";
  34.         break;
  35.         default:
  36.             return false;
  37.         break;
  38.         }
  39.        
  40.     }
  41.    
  42.    
  43.    
  44. </script>
  45. </head>
  46. <body>
  47.     <form>
  48.         <div id="titulo" style="font-size: 250%;"> CASA DE PERROS </div>
  49.         <br/><br/>
  50.         <div id="botones">
  51.         <input type="button" value="¿Dónde estámos? " id="sitio" class="Perrera" />
  52.         <input type="button" value="¿Quienes somos?" id="conocenos" class="Perrera" />
  53.         <input type="button" value="Adopta un perro" id="Adopta" class="Perrera" />
  54.         <input type="button" value="Contactar" id="abandona" class="Perrera" />
  55.         </div>
  56.        
  57.         <div id="caja">
  58.            
  59.         </div>
  60.        
  61.        
  62.        
  63.        
  64.     </form>
  65. </body>
  66. </html>

base de datos:

Código MySQL:
Ver original
  1. CREATE DATABASE proyectoPerrera;
  2.  
  3. use proyectoPerrera;
  4.  
  5. CREATE TABLE trabajador (
  6.     idtrabajador int (20),
  7.     nombre varchar(20) not null,
  8.     contrasenia  VARCHAR(40) not null,
  9.     telefono int (10),
  10.     PRIMARY KEY (idtrabajador)
  11.     );

entrar2.php

Código PHP:
Ver original
  1. <?PHP
  2. // Configura los datos de tu cuenta
  3. $dbhost='localhost';
  4. $dbusername='root';
  5. $dbuserpass='';
  6. $dbname='proyectoPerrera';
  7.  
  8.  
  9. // Conectar a la base de datos
  10. mysql_connect ($dbhost, $dbusername, $dbuserpass);
  11. mysql_select_db($dbname) or die('Cannot select database');
  12.  
  13. if ($_POST['username']) {
  14. //Comprobacion del envio del nombre de usuario y password
  15. $username=$_POST['username'];
  16. $password=$_POST['password'];
  17. if ($password==NULL) {
  18. echo "La password no fue enviada";
  19. }else{
  20. $query = mysql_query("SELECT nombre,contrasenia FROM trabajador WHERE nombre = '$username'") or die(mysql_error());
  21. $data = mysql_fetch_array($query);
  22. if($data['contrasenia'] != $password) {
  23. echo "Login incorrecto";
  24. }else{
  25. $query = mysql_query("SELECT nombre,contrasenia FROM users WHERE nombre = '$username'") or die(mysql_error());
  26. $row = mysql_fetch_array($query);
  27. $_SESSION["s_nombre"] = $row['nombre'];
  28. echo "Has sido logueado correctamente ".$_SESSION['s_nombre']." y puedes acceder al index.php.";
  29. }
  30. }
  31. }
  32. ?>



Código CSS:
Ver original
  1. body {     
  2.             background: url(fondo6.jpg) no-repeat center center fixed;
  3.         -webkit-background-size: cover;
  4.         -moz-background-size: cover;
  5.         -o-background-size: cover;
  6.         background-size: cover;
  7.  
  8.  
  9.          }
  10.    
  11.     a {
  12.         color: black;
  13.         text-decoration:none;
  14.     }
  15.    
  16.     h1 {
  17.         color: black;
  18.         text-decoration: underline;
  19.     }
  20.    
  21.     h3 {
  22.         TEXT-ALIGN:center;
  23.         color: black;
  24.         text-shadow: 5px 5px 5px #A4A4A4;
  25.        
  26.     }
  27.    
  28.     #titulo {
  29.             text-align: center;
  30.             text-shadow: 5px 5px 5px #585858;
  31.             width:340px;
  32.             margin: auto auto;
  33.             margin-top:30px;
  34.             padding-bottom:30px;
  35.             }
  36.    
  37.     #caja {
  38.             display: block;
  39.             border-radius: 15px 15px 15px 15px;
  40.             border: solid black 3px;
  41.             width: 1207px;
  42.             height: auto;
  43.             margin: auto auto;
  44.             padding-left:12px;
  45.             padding-right:12px;
  46.             padding-bottom:30px;
  47.             background-color:#CED8F6;
  48.             }
  49.  
  50.     #botones {
  51.             width: 1238px;
  52.             height: auto;
  53.             margin: auto auto;
  54.             }
  55.    
  56.     .Perrera {
  57.             background-color: black;
  58.             color: white;
  59.             border-radius: 8px 8px 8px 8px;
  60.             width:200px;
  61.             height: 25px;
  62.             }
  63.    
  64.     #mapa {
  65.             margin-left:600px;
  66.             margin-top:-300px;
  67.             margin-bottom:12px;
  68.             border-style: solid;
  69.            
  70.             }
  71.            
  72.     #imagen {
  73.             margin-left:600px;
  74.             margin-top:-300px;
  75.             margin-bottom:12px;
  76.             border-style: solid;
  77.             }
  78.            
  79.     #texto {
  80.             position:left;
  81.             margin-left:70px;
  82.             margin-right:600px;
  83.             padding-right:12px;
  84.             }
  85.    
  86.     #texto2 {
  87.             position:left;
  88.             margin-left:70px;
  89.             margin-right:600px;
  90.             padding-right:12px;
  91.             }
  92.    
  93.     #texto3 {
  94.             position:left;
  95.             margin-left:70px;
  96.             margin-right:500px;
  97.             padding-right:12px;
  98.            
  99.             }
  100.    
  101.     #texto4 {
  102.             position:left;
  103.             margin-right:600px;
  104.             margin-left:70px;
  105.             padding-right:12px;
  106.             }
  107.    
  108.     #texto5 {
  109.            
  110.             margin-left:670px;
  111.             margin-top:-228px;
  112.             margin-bottom:12px;
  113.             width: 600px;
  114.             height: auto;
  115.            
  116.             }
  117.                
  118.     #col_der {
  119.             float: right;
  120.             width: 33%;
  121.             height: 190px;
  122.             padding-top:20px;
  123.             padding-bottom:20px;
  124.             background-color: white;
  125.             text-align: center;
  126.             margin:0 auto;
  127.             background-color:#CED8F6;
  128.             }
  129.  
  130.     #col_izq {
  131.             float: left;
  132.             width: 33%;
  133.             height: 190px;
  134.             padding-top:20px;
  135.             padding-bottom:20px;
  136.             background-color: white;
  137.             text-align: center;
  138.             margin:0 auto;
  139.             background-color:#CED8F6;
  140.             }
  141.    
  142.     #col_cen {
  143.             height: 190px;
  144.             padding-top:20px;
  145.             padding-bottom:20px;
  146.             background-color: white;
  147.             text-align: center;
  148.             margin:0 auto;
  149.             background-color:#CED8F6;
  150.             }
  151.    
  152.     #col_der_texto1 {
  153.             float: right;
  154.             width: 33%;
  155.             height: auto;
  156.             background-color:#CED8F6;
  157.             }
  158.  
  159.     #col_izq_texto2 {
  160.             float: left;
  161.             width: 33%;
  162.             height: auto;
  163.             background-color:#CED8F6;
  164.     }
  165.    
  166.     #col_cen_texto3 {
  167.             height: auto;          
  168.             background-color:#CED8F6;
  169.     }
  170.    
  171.     #imgpequenio {
  172.             border-style: solid;
  173.             border-color: black;
  174.            
  175.     }
  176.  
  177.     #imgmediano {
  178.             border-style: solid;
  179.             border-color: black;
  180.            
  181.     }
  182.    
  183.     #imggrande {
  184.             border-style: solid;
  185.             border-color: black;
  186.     }
  187.    
  188.     #todos_los_perros_texto {
  189.         text-align: center;
  190.     }
  191.    
  192.     #todos_los_perros {
  193.         border-style: solid;
  194.         margin: auto auto;
  195.         width:1000px;
  196.     }  
  197.    
  198.     #login{
  199.             display: block;
  200.             background-color: #FFFFFF;
  201.             margin-left:850px;
  202.             margin-top:-200px;
  203.             margin-bottom:12px;
  204.             width:340px;
  205.             height: 190px;
  206.             border-radius: 15px 15px 15px 15px;
  207.             border: solid black 1px;
  208.             TEXT-ALIGN:center;
  209.             }