session variable problem

Thread Solved

Join Date: Feb 2008
Posts: 20
Reputation: infernojmd is an unknown quantity at this point 
Solved Threads: 0
infernojmd infernojmd is offline Offline
Newbie Poster

session variable problem

 
0
  #1
Nov 7th, 2009
Im trying to use session variables to save the puzzle key, and than open a new file that prints it out, but it gives me
Notice: Undefined index: puzzleName in C:\Apache2.2\htdocs\users\jmdrenning0\wordfind\wordfindkey2.php on line 13

i have no idea what it means, any help please.

wordfind.php
  1. function printPuzzle(){
  2. //print puzzle
  3.  
  4. global $puzzle, $word, $keyPuzzle, $boardData;
  5. //print puzzle itself
  6.  
  7. print <<<HERE
  8. <h1>{$boardData["name"]}</h1>
  9. $puzzle
  10. <h3>Word List</h3>
  11. <u1>
  12.  
  13. HERE;
  14. //print word list
  15. foreach ($word as $theWord){
  16. $theWord = rtrim($theWord);
  17. print "<li>$theWord</li>\n";
  18. }
  19. print "</ul>\n";
  20. $puzzleName = $boardData["name"];
  21.  
  22. //print form for requesting answer key
  23. //save answer key as session variable
  24.  
  25. $_Session["key"] = $keyPuzzle;
  26. $_Session["puzzleName"] = $puzzleName;
  27.  
  28. print <<<HERE
  29.  
  30. <form action = "wordfindkey2.php"
  31. method = "post"
  32. id = "keyForm">
  33.  
  34. <div>
  35. <input type = "submit"
  36. value = "show answer key" />
  37. </div>
  38. </form>
  39.  
  40. HERE;
  41. }

this is wordfindkey2.php
  1. <?php session_start() ?>
  2. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  3. "http://www.w3.org/TR/xhtml/DTD/xhtml1-strict.dtd">
  4. <html lang="EN" dir="ltr" xmlns="http://www.w3.org/1999/xhtml">
  5. <head>
  6. <title>Word Find Answer Key</title>
  7. <link rel="stylesheet" type="text/css" href="wordfind.css" />
  8. </head>
  9. <body>
  10. <?php
  11. // answer key for word find called from session variable
  12.  
  13. $puzzleName = $_SESSION["puzzleName"];
  14. $key = $_SESSION["key"];
  15.  
  16.  
  17. //$_Session["key"] = $keyPuzzle;
  18. //$_Session["puzzleName"] = $puzzleName;
  19. print <<<HERE
  20. <h1>$puzzleName Answer key</h1>
  21. $key
  22. HERE;
  23. ?>
  24. </body>
  25. </html>
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 44
Reputation: phouse512 is an unknown quantity at this point 
Solved Threads: 1
phouse512 phouse512 is offline Offline
Light Poster
 
0
  #2
Nov 7th, 2009
In wordfind.php, when you set the session variables, the session variables should be capitalized like this.

  1. $_SESSION["key"] = $keyPuzzle;
  2. $_SESSION["puzzleName"] = $puzzleName;
Reply With Quote Quick reply to this message  
Join Date: Oct 2006
Posts: 1,092
Reputation: ardav will become famous soon enough ardav will become famous soon enough 
Solved Threads: 138
ardav's Avatar
ardav ardav is offline Offline
Veteran Poster
 
-1
  #3
Nov 7th, 2009
You have named $_SESSION correctly in the second file, but have named it $_Session (incorrect) in the first. Variables are case sensitive.
If you don't reply to your own thread or you can't find the solved link - you're off my Christmas list - permanently! Bah humbug!
Reply With Quote Quick reply to this message  
Join Date: Feb 2008
Posts: 20
Reputation: infernojmd is an unknown quantity at this point 
Solved Threads: 0
infernojmd infernojmd is offline Offline
Newbie Poster
 
0
  #4
Nov 7th, 2009
wow, i feel stupid, i know i have to have it as $_SESSION but didnt realize that was the problem. I put it as $_SESSION["key"] and such. It works fine, thanks guys.
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:




Views: 299 | Replies: 3
Thread Tools Search this Thread



Tag cloud for PHP
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC