+2 votes
consider, i have designed 3 TextBoxes(Student_id,date,semester) in an html form..

when i click submit button all contents are getting cleared from textbox..i want to load the date and semester in textboxes ,but no need to load Student_id in textbox.

how can i solve??can anyone help me find solution using php?
asked Feb 3, 2016 in Computer Science - IT by gypsiii
edited Feb 3, 2016 by slow_learner | 71 views
page is reloading that is the reason why your contents are refreshed..you could try adding some drop box know..
suppose in drop box list we have following options...1st,2nd,3rd....when the page load the default option  1st appear in drop box...but i am selecting 3rd and submit..after submitting the default value 1st comes into the dropbox..but i want to previous selected option 3rd to appear..
only way is save the previous value in session / cookies so that they can be reused

1 Answer

+1 vote

Consider you have textbox semester and button as below :

<input type="text" name="semester"/>
<input type="submit" name="Submit" value="Done" />

Use session in php as below , on submit submit the values :


 if (isset($_POST['Submit'])) { 
 $_SESSION['sem'] = $_POST['semester'];

Retrieve the value stored in session :

echo "<input type='text' name='semester' value='" . htmlspecialchars($_SESSION['sem']) . "'/>"; 
answered Feb 3, 2016 by ppk