Ver Mensaje Individual
  #3 (permalink)  
Antiguo 05/10/2009, 05:19
samu22
 
Fecha de Ingreso: abril-2008
Mensajes: 453
Antigüedad: 16 años, 11 meses
Puntos: 16
Respuesta: nombre web no cambia

una variante a $_POST son las sessiones ahi no vas a tener problemas al refrescar

index.php
Código php:
Ver original
  1. if(isset($_SESSION['p'])){
  2.         include ($_SESSION['p']);
  3.     unset($_SESSION['p']); // borramos la variable de session
  4. }else{
  5.         include ('home.html');
  6. }

send.php
Código php:
Ver original
  1. <?php
  2.     if(isset($_POST['pagina'])){
  3.         $_SESSION['p'] = $_POST['pagina'];
  4.         header('location: index.php');
  5.     }
  6. ?>

home.html
Código html:
Ver original
  1.     <head>
  2.         <title>Prueba formulario </title>
  3.     </head>
  4.     <body>
  5.         <script>
  6.             function post_to_url(path, pagina, method) {
  7.                 // puedes definir el path o dar la opcion de elegir a donde se envia
  8.                 //path = "index.php";
  9.                 method = method || "post";
  10.  
  11.                 var form = document.createElement("form");
  12.                 form.setAttribute("method", method);
  13.                 form.setAttribute("action", path);
  14.            
  15.                        
  16.                 var hiddenField = document.createElement("input");
  17.  
  18.                 hiddenField.setAttribute("type", "hidden");    
  19.                 hiddenField.setAttribute("name",'pagina');
  20.                 hiddenField.setAttribute("value", pagina);
  21.                 form.appendChild(hiddenField);
  22.            
  23.                 document.body.appendChild(form);  
  24.                 form.submit();
  25.             }
  26.  
  27.         </script>
  28.    
  29.         <a href="#" name="usuarios" onclick="post_to_url('send.php','usuarios.php','post')" >usuarios</a>
  30.         <a href="#" name="usuarios" onclick="post_to_url('send.php','noticias.php','post')" >noticias</a>
  31.     </body>
  32. </html>

con esto cuando refresques el index.php va a mostrarte el contenido de home.html nuevamente