473,505 Members | 14,686 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

how to display session varialbe in text box

14 New Member
I am having a search text box. In that box, I want to store the previous search value when the page is loaded next time. For that i created session for the textbox value when the search button is clicked i retrive data from data base and when the value from database is choose then it move to the next page . But i dont know how to replace the session value in the textbox when the page is next loaded. it display an error message( Notice: Undefined index: doj in C:\wamp\www\ Ticket Reservation System\seat.php Call Stack)........Any one Here to solve my Query......? here this is the code for index page........


Expand|Select|Wrap|Line Numbers
  1.  
  2. <?php
  3. include("dbconnect.php");
  4. session_start();
  5. $_SESSION['date'] = 'doj';
  6. $uid = $_SESSION['id']; 
  7. if(isset($_SESSION['id']))
  8. {
  9. ?>
  10. <form  method="POST">
  11. <td width="48" height="32" class="simpletext"> FROM: </td>
  12. <td width="107"><div align="justify">
  13. <select class="html-text-box"; font-style:oblique;      width:100px; font-    family:verdana; font-weight:bold" name="from">
  14. <option value="" selected>:: Departure ::</option>
  15. <option value="ABBOTTABAD">ABBOTTABAD</option>
  16. <option value="BAHAWALPUR" >BAHAWALPUR</option>
  17. <option value="CHINIOT" >CHINIOT</option>
  18. <td width="24" align="right"  class="simpletext"><div align="center">TO:     </div></td>
  19. </select>
  20. <td width="107"  align="left"><select class="html-text-box"     font-  style:oblique; width:100px; font-family:verdana; font-weight:bold"  name="to">                    <option value="" selected>:: Arrival ::</option>
  21. <option value="ABBOTTABAD">ABBOTTABAD</option>
  22. <option value="BAHAWALPUR" >BAHAWALPUR</option>
  23. </select>
  24. <tr>
  25. <td height="32" class="simpletext">DEPERATURE</td>
  26. <td>            
  27. <div data-date-format="yyyy-mm-dd" data-    date="document.write(date())"     class="input-append date myDatepicker"> <input type="text" value="" name="doj"   size="16" class="span2" required><span class="add-on"><i class="icon-calendar">     </i></span>                     
  28. </div></td></div>
  29. <td align="right"  class="simpletext">RETURN:</td>
  30. <td><div data-date-format="yyyy-mm-dd" data-date="document.write(date())"   class="input-append date myDatepicker">
  31. <input type="text" value="" name="doj" size="12" class="span2" required>
  32. <span class="add-on"><i class="icon-calendar"></i></span> </div></td> 
  33. </tr>
  34. <tr>
  35. <td height="34" colspan="4" align="center" valign="middle"><p>
  36. <input type="submit" name="search" value="Search" onClick="return  callfrm(document.getElementById('currentdate').value);"  class="html-button">
  37. <input type="submit" name="resert" value="Reset"  class="html- button">
  38. </p>
  39. <p>&nbsp;</p></td>
  40. </tr>
  41. </form>
  42. <?php
  43. require('dbconnect.php');
  44. mysql_select_db("bus_reservation1 (1)");
  45. if(isset($_POST['search']))
  46. {
  47.  
  48.  $from = $_POST['from'];
  49.  $to = $_POST['to'];
  50.  
  51.  $query = mysql_query("select * from schedule where Destinatio='$from' AND Arriva ='$to'");
  52. $c = mysql_num_rows($query);
  53.  
  54. if (!$query) {
  55. die('Invalid query: ' . mysql_error());
  56. }
  57.  
  58. if($c>0)
  59.  
  60. {
  61. ?>
  62. <table width="898" height="62" align="center" cellpadding="2"      cellspacing="2" class="table" bordercolor="#000000" b>
  63.  
  64. <tr align="center"><td width="120">Destination</td>
  65. <td width="57">Arrival</td>
  66. <td width="121">Departure time</td>
  67. <td width="98">Arrival Time</td>
  68. <td width="44">Fare</td>
  69. <td width="85">Bus_type</td>
  70. <td width="84">Total_Seats</td>
  71. <td width="81">Available</td><td width="52">&nbsp;</td>
  72. </tr>
  73. </section>
  74. <?php
  75. while($r1 = mysql_fetch_array($query))
  76. {
  77. $schedule= $r1['id'];
  78. $Destinatio = $r1['Destinatio'];
  79. $Arriva= $r1['Arriva'];
  80. $Departure_time = $r1['Departure_time'];
  81. $Arrival_time = $r1['Arrival_time'];
  82. $Fare = $r1['Fare'];
  83. $Bus_type = $r1['Bus_type'];
  84. $Total_Seats = $r1['Total_Seats'];
  85. $bust = $schedule.'schedule';
  86. $query1 = mysql_query("SELECT * from $bust where status='Available'");
  87. echo $query1;
  88. if (!$query1) {
  89. die('Invalid query: ' . mysql_error());
  90. }
  91.  
  92. $c = mysql_num_rows($query1);
  93. ?>
  94.  
  95. <tr align="center"><td><?php echo $Destinatio;?></td><td><?php echo     $Arriva;?></td><td><?php echo $Departure_time;?></td><td><?php echo  $Arrival_time;?></td><td><?php echo $Fare;?></td><td nowrap="nowrap"><?php echo $Bus_type;?></td><td><?php echo $c;?></td><td><a href="seat.php?id=<?php echo  $uid;?>&bus=<?php echo $schedule;?>">Book</a>
  96. </td></tr></table>
  97. <script>Cufon.now();</script>
  98. <?php
  99. }
  100. else
  101. {
  102. header("Location:seat.php");
  103. }
  104. }
  105. else
  106. {
  107. header("Location:index.php?id=$uid");
  108. }
  109. ?>
  110.  
  111.  
this is the code that i use for seat page
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. session_start();
  3. $date = $_SESSION['doj'];   
  4. ?>
  5. <?php
  6. $date = strip_tags( utf8_decode( $_POST['doj'] ) );
  7. $query = "select * from seat where date = '" . $date . "'";
  8. $result = mysql_query($query);
  9. {
  10. }           
  11.  
  12. <label>Date of Journey</label>
  13. <?php
  14. echo "<input type='text' class='span2'     name='doj' value='". $date ."' readonly/>";
  15. ?>
  16.  
Jun 12 '15 #1
1 5079
Rabbit
12,516 Recognized Expert Moderator MVP
You named the session variable date, not doj. You set the session variable value to the string doj.
Jun 12 '15 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

4
16007
by: What-a-Tool | last post by:
I want to display a session variable as a textbox value: <input type="text" ...... value="<%=Session("myvar")%>"> I've tried several different variation of this and can't get it to display...
1
1228
by: nithu | last post by:
hi frens, i am an fresh graduate..... n also new to vb..... pls help me.... how to display values in text boxes retrieved from db in printable format? any sort of help or...
2
1289
by: sandhya2006 | last post by:
Hii, I hav a doubt in perl,Assume there is many html files in a folder I have to Take all files and display it into text file without displaying the tags.Please reply atleast for displaying...
1
1839
by: lihao0129 | last post by:
The scenario is a RTF(Rich Text Format) editor where I can input text and meanwhile display 'style'd text or multimedia( i.e bold fonts, pictures, movies ) in the same box... I am currently...
1
1253
by: Anuhas | last post by:
Dear Experts, I need to display a help text when I put my mouse point on a button. Please tell me a way to do this. ...
2
2111
vikas251074
by: vikas251074 | last post by:
I am creating an application for official use. This application will be used by employees to take items for official use. I have a list, presently this list contains three items - 1) Cartridges, ...
2
2205
by: lonelylonely | last post by:
how to display in new text field when i add option from drop down list?
1
1365
by: chibbie23 | last post by:
Hi, I have a table in mssql which holds the data i display on my "News" page. I wanted the user to be able to style the details of the news, so i store the details on a column with a text data...
0
7216
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7098
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7303
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
7018
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7471
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
5028
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
1528
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
754
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
407
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.