MuseiKaze Posted November 9, 2009 Share Posted November 9, 2009 Hi there. Im pretty new to php and this forum, but I was just wondering if I could get some help with part of a chat room that im writing. Basically I have a form where users enter their usernames then I want to put each username into an array and use with a session onto another page where all the users can be echoed as a list. Is this possible? Thanks =) Link to comment https://forums.phpfreaks.com/topic/180810-usernames-into-an-array/ Share on other sites More sharing options...
rajivgonsalves Posted November 9, 2009 Share Posted November 9, 2009 Yes it is why not how is the user inputting the usernames ? what is your code till now Link to comment https://forums.phpfreaks.com/topic/180810-usernames-into-an-array/#findComment-953879 Share on other sites More sharing options...
MuseiKaze Posted November 9, 2009 Author Share Posted November 9, 2009 I dont have anything currently for the user list section currently, I did some experimenting with adding the usernames to a text file each time someone logs in and then deleting that username when they log out, but that didnt really turn out well =P Im still all new to php, so sorry if i dont explain myself heaps well. But I was thinking something like this could be used but im not sure how to store and split each $username = $_POST['username']; into an array. index.php <form action="chat.php" method="post"> <input name="username" type="text" size="25" maxlength="20"> <input value="Login" type="submit"></form> chat.php <?php session_start(); $username = $_POST['username']; $users = array('username[0]','username[1]','username[2]'); $_SESSION['users'] = $users; ?> users.php print $users; Link to comment https://forums.phpfreaks.com/topic/180810-usernames-into-an-array/#findComment-953896 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.