Foros del Web » Programando para Internet » PHP »

Intentando hacer una web modular =(

Estas en el tema de Intentando hacer una web modular =( en el foro de PHP en Foros del Web. Estoy haciendo una web modular, ya hice con switch, pero no logro colocar una página de error cuando colocamos una direccion que no existe index.php?s=mxmxmxmxmxmx ...
  #1 (permalink)  
Antiguo 12/05/2011, 01:41
 
Fecha de Ingreso: febrero-2011
Mensajes: 233
Antigüedad: 13 años, 3 meses
Puntos: 4
Exclamación Intentando hacer una web modular =(

Estoy haciendo una web modular, ya hice con switch, pero no logro colocar una página de error cuando colocamos una direccion que no existe index.php?s=mxmxmxmxmxmx (que no sea default).

Intendando con este código, me sale todo bien, pero cuando ingreso a index.php me sale página no encontrada, o sea solo se puede asi index.php?s=xxxxxxx alguna ayuda para que si acepte y salga la pagina que quiero en index.php AYUDA!.



Código PHP:
<?php

$URL       
$_GET['s'];
$ext      ".html";
$Pagina  $URL.$ext;


if (
$URL == "xxxxxxxxxxxxxxxxxx"){  
   
$Descripcion ='xxxxxxxxxxxxxxxxxxxxxxxx';
   
$Titulo    ='xxxxxxxxxxxxxxxxxxx';
   
$Keyw    ='xxxxxxxxxxxxx';
 }


elseif (
$URL == "xxxxxxxxxxxxxxxxxxxxxxx"){ 
   
$Descripcion ='xxxxxxxxxxxxxxxxxxxxxxxx';
   
$Titulo    ='xxxxxxxxxxxxxxxxxxx';
   
$Keyw    ='xxxxxxxxxxxxx';
 }

// y asi con todas mis páginas


if(file_exists($URL.$ext))
{
include (
"index.html");
}


else 
{
echo 
'
  
<!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=iso-8859-1" />
<meta name="robots" conte="noindex,nofollow" />
<title>Página no encontrada</title>
</head>

<body>Error 404: Página no encontrada
</body>
</html>   
  
  '
; }


?>
  #2 (permalink)  
Antiguo 12/05/2011, 08:33
Avatar de s00rk  
Fecha de Ingreso: octubre-2010
Ubicación: Mexico
Mensajes: 238
Antigüedad: 13 años, 6 meses
Puntos: 48
Respuesta: Intentando hacer una web modular =(

Solamente hacer un check si el $URL esta vacio no hacer nada

Código PHP:
<?php

$URL       
$_GET['s'];
$ext      ".html";
$Pagina  $URL.$ext;

if (
$URL == "xxxxxxxxxxxxxxxxxx"){  
   
$Descripcion ='xxxxxxxxxxxxxxxxxxxxxxxx';
   
$Titulo    ='xxxxxxxxxxxxxxxxxxx';
   
$Keyw    ='xxxxxxxxxxxxx';
 }


elseif (
$URL == "xxxxxxxxxxxxxxxxxxxxxxx"){ 
   
$Descripcion ='xxxxxxxxxxxxxxxxxxxxxxxx';
   
$Titulo    ='xxxxxxxxxxxxxxxxxxx';
   
$Keyw    ='xxxxxxxxxxxxx';
 }

// y asi con todas mis páginas

if(empty($URL))
{
    if(
file_exists("./".$Pagina))
    {
        include (
$Pagina);
    }else {
        echo 
'
  
        <!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=iso-8859-1" />
        <meta name="robots" conte="noindex,nofollow" />
        <title>Página no encontrada</title>
        </head>

        <body>Error 404: Página no encontrada
        </body>
        </html>   
      
          '

    }
}
?>
  #3 (permalink)  
Antiguo 12/05/2011, 10:14
 
Fecha de Ingreso: febrero-2011
Mensajes: 233
Antigüedad: 13 años, 3 meses
Puntos: 4
Respuesta: Intentando hacer una web modular =(

Gracias, con lo que me diste hice una modificación en el código, ahora esta todo correcto excepto.

Código PHP:
<?php

$URL       
$_GET['s'];
$ext      ".html";
$Pagina  $URL.$ext;

if (
$URL == "xxxxxxxxxxxxxxxxxx"){  
   
$Descripcion ='xxxxxxxxxxxxxxxxxxxxxxxx';
   
$Titulo    ='xxxxxxxxxxxxxxxxxxx';
   
$Keyw    ='xxxxxxxxxxxxx';
 }


elseif (
$URL == "xxxxxxxxxxxxxxxxxxxxxxx"){ 
   
$Descripcion ='xxxxxxxxxxxxxxxxxxxxxxxx';
   
$Titulo    ='xxxxxxxxxxxxxxxxxxx';
   
$Keyw    ='xxxxxxxxxxxxx';
 }

// y asi con todas mis páginas

if(empty($URL))
{

echo 
'
  
        <!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=iso-8859-1" />
        <meta name="robots" conte="noindex,nofollow" />
        <title>Página no encontrada</title>
        </head>

        <body>Error 404: Página no encontrada
        </body>
        </html>   
      
          '

    
}
else 

{
   
$Descripcion "xxxx";
   
$Titulo    ='xxxx';
   
$Keyw    ='xxxxx';
   
$Titulo2 "xxxxxxx";
   
$Pagina    ="Indice.html";
   include 
"index.html";
}


?>

Ahora, lo que quiero es que al escribir index.php no me salga el error

Notice: Undefined index: s in C:\wamp\www\Articulos\index.php on line 9

O sea cuando no escriba index.php?s=xxxxx no me salga algun error...

Última edición por tonydx16; 12/05/2011 a las 10:20
  #4 (permalink)  
Antiguo 12/05/2011, 18:21
Avatar de s00rk  
Fecha de Ingreso: octubre-2010
Ubicación: Mexico
Mensajes: 238
Antigüedad: 13 años, 6 meses
Puntos: 48
Respuesta: Intentando hacer una web modular =(

Código PHP:
Ver original
  1. <?php
  2.  
  3. if( isset($_GET['s']) && empty($_GET['s']) )
  4. {
  5.     echo '
  6.  
  7.        <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  8.        <html xmlns="http://www.w3.org/1999/xhtml">
  9.        <head>
  10.        <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  11.        <meta name="robots" conte="noindex,nofollow" />
  12.        <title>Página no encontrada</title>
  13.        </head>
  14.  
  15.        <body>Error 404: Página no encontrada
  16.        </body>
  17.        </html>  
  18.      
  19.          ';
  20.           die();
  21. }
  22.  
  23. $URL       = $_GET['s'];
  24. $ext      = ".html";
  25. $Pagina  = $URL.$ext;
  26.  
  27. if ($URL == "xxxxxxxxxxxxxxxxxx")
  28. {  
  29.    $Descripcion ='xxxxxxxxxxxxxxxxxxxxxxxx';
  30.    $Titulo    ='xxxxxxxxxxxxxxxxxxx';
  31.    $Keyw    ='xxxxxxxxxxxxx';
  32. }elseif ($URL == "xxxxxxxxxxxxxxxxxxxxxxx"){
  33.  
  34.    $Descripcion ='xxxxxxxxxxxxxxxxxxxxxxxx';
  35.    $Titulo    ='xxxxxxxxxxxxxxxxxxx';
  36.    $Keyw    ='xxxxxxxxxxxxx';
  37.    
  38.  }
  39.  
  40. // y asi con todas mis páginas
  41.  
  42.    $Descripcion = "xxxx";
  43.    $Titulo    ='xxxx';
  44.    $Keyw    ='xxxxx';
  45.    $Titulo2 = "xxxxxxx";
  46.    $Pagina    ="Indice.html";
  47.    include "index.html";
  48.  
  49.  
  50. ?>

Etiquetas: modular
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta

SíEste tema le ha gustado a 1 personas




La zona horaria es GMT -6. Ahora son las 04:23.