View unanswered posts | View active topics It is currently Fri Oct 24, 2014 1:02 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

<?php
session_start();
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+");
else
$file = fopen("waiting.txt", "w+");
$game = fread($file, filesize("waiting.txt"));
fclose($file);
$game = session_id();
$file = fopen("waiting.txt");
fputs($file, $game);
fclose($file);
?>


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

Who is online

Users browsing this forum: No registered users and 1 guest


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:  
cron
© Copyright 2003-2008 www.php-editors.com. The ultimate PHP Editor and PHP IDE site.