Reputation: 23
I am currently in the process of designing a Computer Aided Learning package. The welcome screen simply requires the user to type in their name into a text field and click a button which directs them to 'subject selection' page. How would I go about storing the user input and how, if possible, could I refer to the stored value on a seperate html page?
<div id="inputbox">
<form>
<input type="text" name="field" class="textInput" />
</form>
</div>
<div id="introsubmit">
<a href="newgame.html" title="New Game" id="introsubmit"></a>
</div>
Upvotes: 0
Views: 691
Reputation: 5742
HTML:
<div id="inputbox">
<form action="script.php">
<input type="text" name="field" class="textInput" />
</form>
</div>
<div id="introsubmit">
<a href="newgame.html" title="New Game" id="introsubmit"></a>
</div>
That will send the form to script.php (if no 'action' defined, it will send the form to the very same page, if that html is inside script.php
then it will work the same, and if no "method" is defined, if will use GET, you can set <form action="script.php" method="POST">
to change this):
script.php:
<?php
session_start();
$_SESSION['name'] = $_GET['name'];
?>
and then you reuse that variable in the same session, remember to always invoke session_start()
before any output in your php
.
Upvotes: 1