Categories

See More
Popular Forum

MBA (4887) B.Tech (1769) Engineering (1486) Class 12 (1030) Study Abroad (1004) Computer Science and Engineering (988) Business Management Studies (865) BBA (846) Diploma (746) CAT (651) B.Com (648) B.Sc (643) JEE Mains (618) Mechanical Engineering (574) Exam (525) India (462) Career (452) All Time Q&A (439) Mass Communication (427) BCA (417) Science (384) Computers & IT (Non-Engg) (383) Medicine & Health Sciences (381) Hotel Management (373) Civil Engineering (353) MCA (349) Tuteehub Top Questions (348) Distance (340) Colleges in India (334)
See More

Attempting to save user input via HTML form and then refer back to it later

General Tech Learning Aids/Tools

Max. 2000 characters
Replies

usr_profile.png

User

( 5 months ago )

 

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>

usr_profile.png

User

( 5 months ago )

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.

what's your interest


forum_ban8_5d8c5fd7cf6f7.gif