Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP] wartość z sesji w polu wartości formularza
dentopolis
post 10.10.2019, 14:30:21
Post #1





Grupa: Zarejestrowani
Postów: 252
Pomógł: 0
Dołączył: 14.08.2016

Ostrzeżenie: (0%)
-----


pola input formularza mają wartości domyślne.chciałbym aby po wpisaniu jednej litery np."x" w polu input wartość została zapisana dla tej osoby odwiedzającej stronę (inna osoba mogła wpisywać inne wartości). próbowałem znaleźć odpowiedź w sieci ale doszedłem do tego momentu:
ten kod działa na tej stronie: przykład
  1. <?php>
  2. <?php>
  3. ?>
  4. <!doctype html>
  5. <html lang="pl-PL">
  6.  
  7.  
  8. </head>
  9.  
  10. <body>
  11.  
  12. <?php
  13. /*
  14. if (isset($_GET['submit'])) {
  15. session_start();
  16. $_SESSION['rightuppereight'] = $_GET['rightuppereight'];
  17. echo $_GET['rightuppereight'];
  18. $_SESSION['rightuppereight'] = $_GET['rightuppereight'];
  19. echo $_GET['rightuppereight'];
  20.  }
  21. */
  22.  
  23. if(isset($_GET["submit"])){
  24. $_SESSION['rightuppereight']=$_GET['rightuppereight'];
  25. $rightuppereight=$_SESSION['rightuppereight'];
  26. echo "Hi " . $_GET["rightuppereight"];
  27. } else {
  28. $rightuppereight='0';
  29. echo "Welcome Guest!";
  30. }
  31.  
  32.  
  33.  
  34. //$_SESSION['rightupperseven']=$_GET['rightupperseven'];
  35. //$rightupperseven=$_SESSION['rightupperseven'];
  36.  
  37.  
  38. ?>
  39.  
  40.  
  41.  
  42. <?php
  43. ###################################################################
  44. ###################### POCZĄTEK DIAGRAMU ############################
  45. ###################################################################
  46. echo "<form action='' method='get'>";
  47. echo "<table border='0' width='100%' class='table-bordered' align='center' cellspacing='0'>";
  48.  
  49. echo "<tr align='center'>";
  50.  
  51. echo "<td><input type='text' style='text-align:center;' name='rightuppereight' value='$rightuppereight' size='1'></td>";
  52. echo "<td><input type='text' style='text-align:center;' name='rightupperseven' size='1' value='$rightupperseven'></td>";
  53. echo "<td><input type='text' style='text-align:center;' name='16' size='1' value='$rightuppersix'></td>";
  54. echo "<td><input type='text' style='text-align:center;' name='15' size='1' value='$rightupperfive'></td>";
  55. echo "<td><input type='text' style='text-align:center;' name='14' size='1' value='$rightupperfour'></td>";
  56. echo "<td><input type='text' style='text-align:center;' name='13' size='1' value='$rightupperthree'></td>";
  57. echo "<td><input type='text' style='text-align:center;' name='12' size='1' value='$rightuppertwo'></td>";
  58. echo "<td><input type='text' style='text-align:center;' name='11' size='1' value='$rightupperone'></td>";
  59.  
  60. echo "<td style='background:navy;'> </td>";
  61.  
  62. echo "<td><input type='text' style='text-align:center;' name='21' size='1' value='$leftupperone'></td>";
  63. echo "<td><input type='text' style='text-align:center;' name='22' size='1' value='$leftuppertwo'></td>";
  64. echo "<td><input type='text' style='text-align:center;' name='23' size='1' value='$leftupperthree'></td>";
  65. echo "<td><input type='text' style='text-align:center;' name='24' size='1' value='$leftupperfour'></td>";
  66. echo "<td><input type='text' style='text-align:center;' name='25' size='1' value='$leftupperfive'></td>";
  67. echo "<td><input type='text' style='text-align:center;' name='26' size='1' value='$leftuppersix'></td>";
  68. echo "<td><input type='text' style='text-align:center;' name='27' size='1' value='$leftupperseven'></td>";
  69. echo "<td><input type='text' style='text-align:center;' name='28' size='1' value='$leftuppereight'></td>";
  70. echo "</tr>";
  71.  
  72.  
  73.  
  74. #start obrazki górny łuk
  75. echo "<tr align='center'>";
  76. echo "<td>";
  77.  
  78. if ($rightuppereight == 'x') {
  79. echo "<img src='gfx/x.png' style='width:50px;'>";
  80. }
  81. elseif ($rightuppereight == 'w') {
  82. echo "<img src='gfx/w.png' style='width:50px;'>";
  83. }
  84. elseif ($rightuppereight == 'c') {
  85. echo "<img src='gfx/c.png' style='width:50px;'>";
  86. }
  87. elseif ($rightuppereight == 'o') {
  88. echo "<img src='gfx/o.png' style='width:50px;'>";
  89. }
  90. elseif ($rightuppereight == 'e') {
  91. echo "<img src='gfx/e.png' style='width:50px;'>";
  92. }
  93. elseif ($rightuppereight == 'i') {
  94. echo "<img src='gfx/i.png' style='width:50px;'>";
  95. }
  96. elseif ($rightuppereight == 'v') {
  97. echo "<img src='gfx/v.png' style='width:50px;'>";
  98. }
  99. elseif ($rightuppereight == '-') {
  100. echo "";
  101. }
  102. elseif ($rightuppereight == '') {
  103. echo "<img src='gfx/tooth.jpg' width='50px'>";
  104. }
  105.  
  106. else {
  107. echo "<img src='gfx/tooth.jpg' width='50px'>";
  108. }
  109. echo "</td>";
  110. echo "</tr>";
  111.  
  112. echo "</table>";
  113.  
  114.  
  115.  
  116.  
  117.  
  118.  
  119.  
  120.  
  121.  
  122.  
  123. echo " <input type='submit' value='submit'>";
  124. echo "</form>";
  125.  
  126.  
  127.  


Ten post edytował dentopolis 10.10.2019, 19:15:45
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Wersja Lo-Fi Aktualny czas: 26.04.2024 - 11:45