Dr Ben Warne Posted December 6, 2006 Share Posted December 6, 2006 So far i have this code<?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(); }?>But from that i want to, on entry, create a text file that will put the session id into it to wait for another id to joinBUT i want it to search to see whether the file exists (to see if someone is already waiting) the go to a new screenI have this code previously$file = fopen("count.txt", "r+");$count = fread($file, filesize("count.txt"));fclose($file);$count += 1;$file = fopen("count.txt", "w+");fputs($file, $count);fclose($file);echo "You are visitor $count";That writes to a text file, but i cant adapt it. Any help would be greatly appretiated!Ben Quote Link to comment Share on other sites More sharing options...
Dr Ben Warne Posted December 6, 2006 Author Share Posted December 6, 2006 Can anyone help? Im still having no luck >:( Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted December 6, 2006 Share Posted December 6, 2006 Take a look at the function [url=http://www.php.net/file_exists]file_exists()[/url].You should test that the file exists before writing to it...Ken Quote Link to comment Share on other sites More sharing options...
Dr Ben Warne Posted December 7, 2006 Author Share Posted December 7, 2006 [quote author=kenrbnsn link=topic=117595.msg480066#msg480066 date=1165441352]Take a look at the function [url=http://www.php.net/file_exists]file_exists()[/url].You should test that the file exists before writing to it...Ken[/quote]How do i get it to create a new file and put the session id in though? Quote Link to comment Share on other sites More sharing options...
Dr Ben Warne Posted December 7, 2006 Author Share Posted December 7, 2006 Is there a code that creates a file and adds to it? Quote Link to comment Share on other sites More sharing options...
Dr Ben Warne Posted December 8, 2006 Author Share Posted December 8, 2006 Ia ir function create? Quote Link to comment Share on other sites More sharing options...
Orio Posted December 8, 2006 Share Posted December 8, 2006 [url=http://php.net/fopen]fopen()[/url] basicly opens files. But if the file doesnt exist, it creates it (and then opens it). So you just need to use [url=http://php.net/fopen]fopen()[/url] :)Orio. Quote Link to comment Share on other sites More sharing options...
Qtix Posted December 8, 2006 Share Posted December 8, 2006 for what do you want to use it?cause its best to avoid fopen and fwrite Quote Link to comment Share on other sites More sharing options...
Dr Ben Warne Posted December 8, 2006 Author Share Posted December 8, 2006 [quote author=Qtix link=topic=117595.msg481025#msg481025 date=1165575298]for what do you want to use it?cause its best to avoid fopen and fwrite[/quote]What i want it for one person to get a session id, and then for someone else to aswell so i can pass an array between the 2 users Quote Link to comment Share on other sites More sharing options...
Dr Ben Warne Posted December 10, 2006 Author Share Posted December 10, 2006 any ideas? Quote Link to comment Share on other sites More sharing options...
Dr Ben Warne Posted December 11, 2006 Author Share Posted December 11, 2006 [quote author=Dr Ben Warne link=topic=117595.msg481888#msg481888 date=1165709433]any ideas?[/quote]Any?? Quote Link to comment Share on other sites More sharing options...
trq Posted December 11, 2006 Share Posted December 11, 2006 [url=http://php.net/fopen]fopen[/url]. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.