This is an old revision of the document!
In this activity you will create a form and use it to pass data from one page to another.
form.php
<?php include('header.php'); include('menu.php'); ?> <main> <p>Choose your hero.</p> <ol> <li><a href="process_form.php?name=Loki">Loki</a></li> <li><a href="process_form.php?name=Hulk">Hulk</a></li> </ol> </main> <?php include('footer.php'); ?> **process_form.php** <code><?php include('header.php'); include('menu.php'); ?> <main> <p>You have chosen <?php echo $_GET['name']; ?></p> </main> <?php include('footer.php'); ?>
<main>
tag.<form>
tag has a parameter called <action>
. This is where you want to send your data.action
to 'process_form.php'.<form>
tags.<button type="submit" name="name" value="Loki"></button> <button type="submit" name="name" value="Hulk"></button>
type
to 'submit' means that when we click the button it will submit the form and send the data. Both buttons will do this.name
is the parameter name to be sent. Submit buttons will often be named 'submit' and not contain data, but sometimes there will be two forms on a page (or sent to a page) and you need to know which one to process.value
is the text that will appear on the button.