Skip to content

Instantly share code, notes, and snippets.

@AndreaBarghigiani
Last active May 3, 2017 14:24
Show Gist options
  • Save AndreaBarghigiani/f0735e2bd152e157ed5e7dda49d07fd3 to your computer and use it in GitHub Desktop.
Save AndreaBarghigiani/f0735e2bd152e157ed5e7dda49d07fd3 to your computer and use it in GitHub Desktop.
Passare informazioni tra una pagina e un'altra
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Ottengo i dati del modulo</title>
</head>
<body>
<h1>Ottengo i dati del modulo</h1>
<?php
if( $_GET['invio'] ){
echo "Sono stati inviati dei dati.";
} else {
echo "Non è stato inviato niente.";
}
?>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Ottengo i dati del modulo</title>
</head>
<body>
<h1>Ottengo i dati del modulo</h1>
<?php if( $_GET['invio'] ): ?>
<h2>Benvenuto <?php echo $_GET['nome'] . ' ' . $_GET['cognome']; ?></h2>
<p>
Ti trovi sulle pagine di skillsAndMore ed è un piacere vederti nuovamente al suo interno.
</p>
<?php else : ?>
<h2>Non è stato inviato niente.</h2>
<?php endif; ?>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Lezione 11 - Passiamo i dati tra pagine con PHP</title>
</head>
<body>
<?php if( $_GET['invio'] ) : ?>
<h1>I dati sono stati passati alla stessa pagina</h1>
<p>
Adesso posso mostrare tutto ció che è stato passato in una lista:
<?php foreach( $_GET as $key => $value ){
echo '<br/>' . $key . " - " . $value;
}
?>
</p>
<?php else : ?>
<h1>Passiamo dati tra pagina con PHP</h1>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>">
<input type="text" name="nome" id="nome">
<input type="text" name="cognome" id="cognome">
<input type="submit" value="Invia Dati" name="invio" id="invio">
</form>
<?php endif; ?>
</body>
</html>
<form action="pagina1.php">
<input type="text" name="nome" id="nome">
<input type="text" name="cognome" id="cognomesasdsadsadsadasdas
<input type="submit" value="Invia Dati" name="invio" id="invio">
</form>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment