User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 402,405 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,001 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting

Carrying Session via URL

Join Date: May 2008
Posts: 1
Reputation: ellabean is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
ellabean ellabean is offline Offline
Newbie Poster

Carrying Session via URL

  #1  
May 9th, 2008
Hi everyone.

I'm thiiis close to losing my wits over this. I'm working on carrying Session ID via the url (not secure, I know, but it's not meant to be) and I cannot for the life of me get this to work.

This is a hangman script (pre-written by someone else) that I need to carry the session id from the alphabet letters through the rest of the game and through both play again links. I think the trouble I'm having is the rest of my session ID links were neat ___.php links, rather than what these are, and I've tried every way I can think of to pass the SID without luck.

<?php
session_name ('YourVisitID');
ini_set('session.use_cookies', 0); // Don't use cookies.
session_start();

$Category = "Animals";
# list of words (phrases) to guess below, separated by new line
$list = "
Dog
Cat
Mouse
Lion
Bear"; 

    # if the current alphabet NOT found in the selected letters
    # at the link, add the currently selected letter
    else
    { $links .= "\n<A HREF=\"$self?letters=$alpha[$c]$letters&n=$n\">$alpha[$c]</A> "; }
  }
  # update the number of wrong choices
  # display a corresponding image
  $nwrong=$wrong; 
  if ($nwrong>6) $nwrong=6;
  echo "\n<p><BR>\n<IMG src=\"hangman_$nwrong.gif\" ALIGN=\"MIDDLE\" BORDER=0 WIDTH=100 HEIGHT=100 ALT=\"Wrong: $wrong out of $max\">\n";
  # if reached the max wrong trials
  if ($wrong >= $max)
  {
    $n++; # get the next word
    if ($n>(count($words)-1)) $n=0; # if the last, back to the first
    echo "<BR><BR><H1><font size=5>\n$word_line</font></H1>\n";
    echo "<p><BR><FONT color=\"red\"><BIG>SORRY, YOU ARE HANGED!!!</BIG></FONT><BR><BR>";
    if (strstr($word, " ")) $term="phrase"; else $term="word"; #check if phrase
    echo "The $term was \"<B>$word</B>\"<BR><BR>\n";
    echo "<A HREF=$self?n=$n".SID.">Play again.</A>\n\n";
  }
  
  # if not reached the max wrong trials 
  else
  {
    echo " &nbsp; # Wrong Guesses Left: <B>".($max-$wrong)."</B><BR>\n";
    echo "<H1><font size=5>\n$word_line</font></H1>\n";
    echo "<P><BR>Choose a letter:<BR><BR>\n";
    echo "$links\n";
  }
}

# if all the letters are matched ($done is true (1)) 
else
{
  $n++; # get next word
  if ($n>(count($words)-1)) $n=0; # if the last, back to the first
  echo "<BR><BR><H1><font size=5>\n$word_line</font></H1>\n";
  echo "<P><BR><BR><B>Congratulations!!! &nbsp;You win!!!</B><BR><BR><BR>\n";
  echo "<A HREF=$self?n=$n".SID.">Play again</A>\n\n";
}
?>

Any help is very much appreciated!
Last edited by ellabean : May 9th, 2008 at 9:31 pm.
AddThis Social Bookmark Button
Reply With Quote  
All times are GMT -4. The time now is 1:46 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC