473,549 Members | 2,741 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)........A ny 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 5101
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
16017
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 properly with any. Help please? Sean
1
1232
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 suggestions would be appreciated.
2
1293
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 the html to text .
1
1849
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 using some HTML tags in textarea and make a "preview" and a "refresh" button to sync between the writepad(textarea) and the preview zone(div). But...
1
1254
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. Anuhas
2
2117
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) Floppy, 3) CD Note : If a user selects Cartridges then list of printer should display, And if floppy or CD is selected, then 'purpose' text...
2
2210
by: lonelylonely | last post by:
how to display in new text field when i add option from drop down list?
1
1371
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 type. i use freetextbox to let the user customize the details section of the news. It's working fine when i show the whole news on a page, with the...
0
7450
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7957
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
6043
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5088
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3500
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3481
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1941
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 we have to send another system
1
1059
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
763
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.