0

I'm creating a program connected to a database where I have a login and then two other pages. When I click the button on the 'pagina 1' it goes to the 'pagina 2', in this page I have a button and I want to put an image or an icon on it. Is there a way to do it?

<html>
<head>
    <title> Agenzia Viaggi </title>
</head>
<body>
    <?php
    $servername = "localhost";
    session_start();
        if(!(isset($_POST["pagina"]))){
        echo "
            <form action='Login.php' method='post'>
                User:<input type='text' name ='utente' /> <br/>
                Password: <input type='password' name ='pwd'/><br/>
                <input type ='submit' value='Accedi'/>
                <input type='hidden' name='pagina' value='1' />
            </form>";
    }else if($_POST["pagina"]==1){
        $utente = $_POST["utente"];
        $password = $_POST["pwd"];
        $conn = new mysqli($servername, $utente, $password, 'agenziaviaggi');
        if($conn->connect_errno){
            echo "Connessione impossibile: ".$conn->connect_error;
            exit;
        }
        $_SESSION["utente"] = $utente;
        $_SESSION["pwd"] = $password;
        
        echo "Aeroporto  ";
        echo "<form action ='Login.php' method = 'post'>
            <input type = 'submit' name = 'aeroporto' value = 'Visualizza Aeroporto'>
            <input type = 'hidden' name = 'pagina' value = '2'/>
        </form>";
    }
    else if($_POST["pagina"]==2){
        $utente = $_SESSION["utente"];
        $password = $_SESSION["pwd"];
        $conn = new mysqli($servername, $utente, $password, 'agenziaviaggi');
        if($conn->connect_errno){
            echo "Connessione impossibile: ".$conn->connect_error;
            exit;
        }
        echo 'Aeroporto<br/>' ;
        $sql = "SELECT Nome, Città, Servizi, Parcheggi, Telefono FROM aeroporto";
        $result = $conn->query($sql);

        if ($result->num_rows > 0) {
            while($row = $result->fetch_assoc()) {
                echo "<br> Nome: ". $row["Nome"]. " - Città: ". $row["Città"]. " - Servizi: ". $row["Servizi"]. " - Parcheggi: ". $row["Parcheggi"]. " - Telefono: ". $row["Telefono"]. "<br>";
            }
        } else {
            echo "0 results";
        }

        echo "<form action ='Login.php' method = 'post'>
            <input type = 'submit' value = 'Go back'>
            <input type = 'hidden' name = 'pagina' value = '1'/>
        </form>";   
    }
    ?>
</body></html>
  • 1
    See input type="image" : https://stackoverflow.com/a/15445393/17856705 . acts like a submit button with image. – Gardener Apr 29 '22 at 13:59

0 Answers0