Buongiorno, gentilmente vi chiedo un pò di aiuto, sono nuovo con PHP ho creato delle pagine, in una vorrei inserire il codice per far si che un utente quando effettua il logout PHP dovrebbe:
a) richiamare la pagina di login
b) distrugegre la sessione precedente e/o aperte
Codice PHP:
<?php
$univoco 
$_COOKIE['univoco'];
if(
$univoco == "" || preg_match("([<>&(),%'?+])"$univoco) || preg_match('/"/'$univoco)){header("Location: ../00_BASE01/login001.php?logout=si");}
include 
'../00_BASE01/CONFIG001.php';
$mysqli = new mysqli($host$username_db$password_db$db_name) or die( "Unable to connect");$mysqli->select_db($db_name) or die( "Unable to select database");mysqli_set_charset($mysqli,"utf8");$query="SELECT id,nome,cognome,email FROM $tabellaUtenti WHERE univoco = '$univoco'";$result $mysqli->query($query) or die( "Unable to query");$num mysqli_num_rows($result);$logdb mysqli_fetch_row($result);$mysqli->close();$id $logdb['0'];$nome $logdb['1'];$cognome $logdb['2'];$email $logdb['3'];
if (
$num 1) {header("Location: ../00_BASE01/login001.php?logout=si");}
?>
<html><meta content="text/html; charset=UTF-8" http-equiv="content-type"><head>    <title>TITOLOPAGINA</title>    <link rel="stylesheet" href ="../00_BASE01/base01.css"></head>
<body style="text-align: center; color: #050049;"><table width="696" height="140" border="1" align="center">  <tbody>    <tr>      <th width="109" align="center" valign="middle" scope="col"><p><img src="todo_se_puede_BASE_BLACK.jpg" width="104" height="104" alt=""/></p>      <p><a href="https://www.sitoweb.it">HOME</a></p></th>      <th width="793" height="134" align="center" valign="middle" scope="col"><span style="text-align: center"></span>        <table width="551" height="80" border="1" align="center">          <tbody>            <tr>              <td width="541" align="center" valign="middle" nowrap="nowrap" style="text-align: center" scope="col"><h3 style="text-align:center;">Base 1</h3></td>            </tr>            <tr>              <td align="center" valign="middle" nowrap="nowrap" style="text-align: center"><p>Benvenuto <? echo $nome." ".$cognome?>                </p></td>            </tr>            <tr>              <td align="center" valign="middle" nowrap="nowrap" style="text-align: center"><p>La tua mail è <? echo $email?>                </p></td>            </tr>            <tr>              <td align="center" valign="middle" nowrap="nowrap" style="text-align: center"><p>Il tuo ID utente è <?php echo $id?>                </p></td>            </tr>            <tr>                <!-- <a href="login001.php?logout=si">Logout</a> -->              <td align="center" valign="middle" nowrap="nowrap" style="text-align: center"><p><a href="login001.php?logout=si">Logout</a></td>            </tr>          </tbody>      </table></th>
Inserisco il codice che ho creato sperando che mi possiate dire dove e cosa inserire per fare quello che ho bisogno.
Grazie mille