View unanswered posts | View active topics It is currently Mon Sep 26, 2022 11:50 am

Reply to topic  [ 1 post ] 
 Passing variables 
Author Message
Junior Member

Joined: Mon Dec 04, 2006 8:53 am
Posts: 2
Post Passing variables
The code below is supposed to log two people on using a text file placing the first "player" waiting for another, once a 2nd "player" is present loading a html screen.

Also i would like to then pass an array variable between them. Thanks for helping!
Dr Ben

if (!isset($_POST['submit'])) {
echo "<form method='post'>";
echo " your name?<input type='text' name='uname'>";
echo " <input type='submit' name='submit'>";
echo "</form>";
} else {
$_SESSION['uname'] = $_POST['uname'];
echo "Welcome {$_SESSION['uname']}, your session id is ". session_id();

if (file_exists (waiting.txt))
fopen("battleships.html", "r+");
$file = fopen("waiting.txt", "w+");
$game = fread($file, filesize("waiting.txt"));
$game = session_id();
$file = fopen("waiting.txt");
fputs($file, $game);

Mon Jan 01, 2007 1:28 pm
Report this post
Display posts from previous:  Sort by  
Reply to topic   [ 1 post ] 

Who is online

Users browsing this forum: No registered users and 0 guests

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
© Copyright 2003-2008 The ultimate PHP Editor and PHP IDE site.