Visualizzazione dei risultati da 1 a 9 su 9
  1. #1
    Utente di HTML.it L'avatar di gaten
    Registrato dal
    Jul 2007
    Messaggi
    1,269

    Ho un problema con header aiutatemi!!!

    allora devo inserrie un header in una pagina che si chiama homepage.php haeder deve essere in questo modo <?php header("location:sito/pagina.html"); ?> ecco questa è la pagina homepage.php :




    <?php
    if (!isset($_SESSION)) {
    session_start();
    }
    $MM_authorizedUsers = "";
    $MM_donotCheckaccess = "true";

    // *** Restrict Access To Page: Grant or deny access to this page
    function isAuthorized($strUsers, $strGroups, $UserName, $UserGroup) {
    // For security, start by assuming the visitor is NOT authorized.
    $isValid = False;

    // When a visitor has logged into this site, the Session variable MM_Username set equal to their username.
    // Therefore, we know that a user is NOT logged in if that Session variable is blank.
    if (!empty($UserName)) {
    // Besides being logged in, you may restrict access to only certain users based on an ID established when they login.
    // Parse the strings into arrays.
    $arrUsers = Explode(",", $strUsers);
    $arrGroups = Explode(",", $strGroups);
    if (in_array($UserName, $arrUsers)) {
    $isValid = true;
    }
    // Or, you may restrict access to only certain users based on their username.
    if (in_array($UserGroup, $arrGroups)) {
    $isValid = true;
    }
    if (($strUsers == "") && true) {
    $isValid = true;
    }
    }
    return $isValid;
    }

    $MM_restrictGoTo = "protezione_pagina.php";
    if (!((isset($_SESSION['MM_Username'])) && (isAuthorized("",$MM_authorizedUsers, $_SESSION['MM_Username'], $_SESSION['MM_UserGroup'])))) {
    $MM_qsChar = "?";
    $MM_referrer = $_SERVER['PHP_SELF'];
    if (strpos($MM_restrictGoTo, "?")) $MM_qsChar = "&";
    if (isset($QUERY_STRING) && strlen($QUERY_STRING) > 0)
    $MM_referrer .= "?" . $QUERY_STRING;
    $MM_restrictGoTo = $MM_restrictGoTo. $MM_qsChar . "accesscheck=" . urlencode($MM_referrer);
    header("Location: ". $MM_restrictGoTo);
    exit;
    }
    ?><!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=utf-8" />
    <title>Documento senza titolo</title>
    </head>

    <body>
    Ciao Benvenuto nel mio sito
    </body>
    </html>
    Con i sogni possiamo conoscere il futuro...

  2. #2
    Utente di HTML.it L'avatar di gianiaz
    Registrato dal
    May 2001
    Messaggi
    8,027
    ma devi mettero in un caso particolare, o che avvenga sempre?

    nel secondo caso mettilo all'inizio della pagina, in ogni caso mettilo sempre prima di aver dato un output alla pagina.

    Oltre che essere fuori regolamento è estremamente scortese postare 2 volte lo stesso problema nel giro di poche ore... tutt'al più riporti l'attenzione al tuo post con una risposta al tuo primo messaggio.

  3. #3
    Utente di HTML.it L'avatar di gaten
    Registrato dal
    Jul 2007
    Messaggi
    1,269
    Scusatemi per questo però siccome lo avevo fatto ieri e nessuno mi aveva risposto!
    Con i sogni possiamo conoscere il futuro...

  4. #4
    Utente di HTML.it L'avatar di gianiaz
    Registrato dal
    May 2001
    Messaggi
    8,027
    a dire il vero c'è un tuo messaggio identico delle 13 di oggi.

    Comunque dai una lettura al regolamento :-)

  5. #5
    Utente di HTML.it L'avatar di gaten
    Registrato dal
    Jul 2007
    Messaggi
    1,269
    Allora cmq il fatto di aprirmi la pagina dopo aver fatto il login va bene però se io metto www.gaten91.altervista.org/sito/index.html si apre lo stesso senza effetuando il login ecco la pagina homepage.php:


    <?php header("location:sito/index.html"); ?>
    <?php
    if (!isset($_SESSION)) {
    session_start();
    }
    $MM_authorizedUsers = "";
    $MM_donotCheckaccess = "true";

    // *** Restrict Access To Page: Grant or deny access to this page
    function isAuthorized($strUsers, $strGroups, $UserName, $UserGroup) {
    // For security, start by assuming the visitor is NOT authorized.
    $isValid = False;

    // When a visitor has logged into this site, the Session variable MM_Username set equal to their username.
    // Therefore, we know that a user is NOT logged in if that Session variable is blank.
    if (!empty($UserName)) {
    // Besides being logged in, you may restrict access to only certain users based on an ID established when they login.
    // Parse the strings into arrays.
    $arrUsers = Explode(",", $strUsers);
    $arrGroups = Explode(",", $strGroups);
    if (in_array($UserName, $arrUsers)) {
    $isValid = true;
    }
    // Or, you may restrict access to only certain users based on their username.
    if (in_array($UserGroup, $arrGroups)) {
    $isValid = true;
    }
    if (($strUsers == "") && true) {
    $isValid = true;
    }
    }
    return $isValid;
    }

    $MM_restrictGoTo = "protezione_pagina.php";
    if (!((isset($_SESSION['MM_Username'])) && (isAuthorized("",$MM_authorizedUsers, $_SESSION['MM_Username'], $_SESSION['MM_UserGroup'])))) {
    $MM_qsChar = "?";
    $MM_referrer = $_SERVER['PHP_SELF'];
    if (strpos($MM_restrictGoTo, "?")) $MM_qsChar = "&";
    if (isset($QUERY_STRING) && strlen($QUERY_STRING) > 0)
    $MM_referrer .= "?" . $QUERY_STRING;
    $MM_restrictGoTo = $MM_restrictGoTo. $MM_qsChar . "accesscheck=" . urlencode($MM_referrer);
    header("Location: ". $MM_restrictGoTo);
    exit;
    }
    ?><!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=utf-8" />
    <title>Documento senza titolo</title>
    </head>

    <body>
    <?php header("location:sito/index.html"); ?>
    </body>
    </html>
    Con i sogni possiamo conoscere il futuro...

  6. #6
    Utente di HTML.it L'avatar di gaten
    Registrato dal
    Jul 2007
    Messaggi
    1,269
    Mi leggete!!!???
    Con i sogni possiamo conoscere il futuro...

  7. #7
    Utente di HTML.it L'avatar di gianiaz
    Registrato dal
    May 2001
    Messaggi
    8,027
    guarda che non è una chat, a volte possono passare ore prima che uno ti risponde.

    Inoltre il codice sparato li cosi non aiuta a capire cosa vuoi fare...

    Impara un po' di netiquette.

  8. #8
    Utente di HTML.it L'avatar di gaten
    Registrato dal
    Jul 2007
    Messaggi
    1,269
    Allora devo inserire header però se lo metto sopra a tutto la pagina se io scrivo cosi www.gaten91.altervista.org/sito/pagina.html non c'è bisogno di fare il login invece voglio metterci una protezione che se non fai il login non puoi entrare cosi facilmente capito?
    Con i sogni possiamo conoscere il futuro...

  9. #9
    Utente di HTML.it
    Registrato dal
    May 2006
    Messaggi
    442
    ciao una solòuzione è questa:

    login.php

    Codice PHP:
    <form 'action='pagina.html' method='post' >
          <table width='
    50%' border='0' align='center' cellpadding='4' cellspacing='0'>
          <tr>
          <td width='
    22%'>Username</td>
          <td width='
    78%'><input name='nick' type='text' id='username'></td>
          </tr>
          <tr>
          <td>Password</td>
          <td><input name='
    passwd' type='password'></td>
          </tr>
         <tr>
        <td><input type='
    submit' name='Submit' value='Entra'></td>
        </tr>
        </table>
        

        echo " </form> 
    poi in pagina.html dopo il controllo della sessione

    if(isset($_POST['Submit']))
    {

    ---qui copi tutto il coddice che viene dopo il controllo della sessione------
    }
    else
    {
    echo "<script>alert(\"Non hai i permessi per accedere a questa pagina o non sei registrato\"); self.location.replace(\"altra_pagina.php\");</script>";
    }

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.