Quantcast
Channel: Active questions tagged html - Stack Overflow
Viewing all articles
Browse latest Browse all 67556

Variable from HTML to PHP

$
0
0

Sorry for the trivial question but I'm creating a web application and for various reasons I need to pass a variable from html to PHP. My code is:

HTML


<form action='nameShow.php' method='POST' enctype='multipart/form-data'>
      <select name = 'nameU' id='nameU'>
         <?php
             $sql = mysqli_query($db, "SELECT nome, cognome FROM utenti");
             echo ("<option value = 'hi'> all </option>");
             while ($row = $sql->fetch_assoc()){
                  echo "<option value=". $row['name'] .">" . $row['name'] . "" . $row['surname'] . "</option>";
             }
         ?>
      </select>  <br/>
      <div class='centro'>
            <input type='submit' class='inputColor centro' value='Conferma' name='submit'>
      </div>
</form> 

PHP

<?php
    $idU = mysqli_real_escape_string($db,$_POST['nameU']);
    $_SESSION['idU'] = $idU;
    echo $idU;
    $id = $_SESSION['idU'];
    echo $id;
?> 

The problem is that after sending the form in PHP it appears that I haven't sent anything, can anyone tell me why?


Viewing all articles
Browse latest Browse all 67556

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>