|
|
Posted in Computers & Tech / How-To's and Tutorials / Programming / PHP
Author: Feelay Total-Replies: 41 Hi! It was a long time ago I created a tutorial, so I've decided to create a new one This time, I am going to teach you, how to create a "user profile page". Lets say I am logged in on my account, and want to view someone else account information (in this case, only his username, but you can add more things later). Then I'll press on a link, that will take me to his user profile. But before you can do that, you will have to create a register script, and a login script. If you don't know how to create any of those, you can find tutorials here: Login-Scipt Tutorial Register-Script Tutorial You will be using the same database, as the earlier tutorials. Before I start, I just want to say that I would never have learned this, without some guys here on Astahost. So don't give me all the credits. I think that vujsa, mastercomputers, Mordent and ethergeek, deserve some credits too. Because they teached me some of these things, that I am going to teach you. Lets start with the "Member List". To be able to see all the members that's registered on the page, with a link to their profile, we need a member list page. Lets start with the code. Members.php [code]<?php session_start(); require 'database.php'; $nuser=$_SESSION['user']; $auser=$_SESSION['admin']; if($nuser){ $userfinal=$nuser; }elseif($auser){ $userfinal=$auser; } if(isset($userfinal)){ $Members = mysql_query("SELECT user FROM characters WHERE level ='1' ORDER BY exp DESC") or die(mysql_error()); $numRowsMembers = mysql_num_rows($Members); ?> <table border="0"> <?php for($count = 1; $count <= $numRowsMembers; $count++) { $name = mysql_fetch_array($Members); ?> <tr> <?php echo '<td><a href="member_profile.php?username=' . $name['user'] . '">' . $name['user'] . '</a></td>'; ?> </tr> <?php } ?> </table>[/code] So.. This is the Member List. I called it "members.php". I think you want to know what it does, or? The first thing we do, after the PHP tag, is starting a session. Not so hard.. Then we require the database file (I'll add it in the end of this tutorial). Then, I create two variables. The "$nuser" is for the "non-admin" user (normal user). The "$auser" is for the "Admin" user. After that I've created theese two variables, I check if the user is an Admin, or a Normal user, and insert the $nuser and $auser variable in the $userfinal variable. now it is easy to check if the user is logged in. Instead of first checking if a Normal user is logged in, and then check if an admin is logged, I check if both is logged in, much faster. (hard to explain Now this explanation was for the "if(isset($userfinal)){" part. After that, I create two new variables again. The first one will get all the "Normal users" from the database. The other one will retrieve the number of rows from the first query. Then I create an Invisible Table, so that the names looks good, and so that the table don't screw up the design (if you use one.) But OFC, if you want to make the table visible, you can change the "border" to a number larger than 0. Now after that, we create a for-loop, to show all the names on the screen (the member list), and all the names, will have a link to their profile. easy, wasn't it? If there is something you didn't understand, you are free to contact me and ask. Now lets begin with the "member_profile" page. member_profile.php [code]<?php session_start(); require 'database.php'; $nuser=$_SESSION['user']; $auser=$_SESSION['admin']; if($nuser){ $userfinal=$nuser; }elseif($auser){ $userfinal=$auser; } if(isset($userfinal)){ $username = $_GET['username']; $user = mysql_query("SELECT * FROM user WHERE username = '$username'"); $user=mysql_fetch_assoc($user); if($user['level'] > 1){ die("You cant view an Admins profile!"); } echo "<h1>User Info</h1>"; echo "<b>Username:".$user['username']."<br>"; echo "<br>"; echo '<form name="backlistfrm" method="post" action="members.php">'; echo '<input type="submit" value="Back to The List">'; echo '</form>'; echo "<br>"; ?>[/code] Here we start like we did in the first page. After the php tag, We start a session, and require the database file. then we create two variables ($auser = admin and $nuser= normal user). Then we create the $userfinal variable, to check if the user is logged in later in the script. Then we create some variables. [code]$username = $_GET['username'];[/code] This is the variable for the name that we pressed on in the member list page. [code]$user = mysql_query("SELECT * FROM user WHERE username = '$username'");[/code] This variable will select all the info about that person. [code]$user=mysql_fetch_assoc($user);[/code] This will make us able to select something specific about that person when we are writing the code. Now we check if the user that we selected is a normal user, or an admin. If the user is an admin, an error will occur that the user can't view the admins profile. If you want you can remove this part: [code]if($user['level'] > 1){ die("You cant view an Admins profile!"); }[/code] This will make the users able to view an admins profile. Then the info about the user will be shown. In this case, I've only added the username of the user -> [code]echo "<b>Username:".$user['username']."<br>";[/code] But OFC, you can add more. Just change the user inside the ['...'] to something else from the database table, that you want to show. (lets say you want to show the users Admin level instead of his username, then you can change the $user['username'] to $user['level'].) The last thing I do in this script, is adding a button that will take the user back the the member_list. And here is the database.php file: [code]<? $con = mysql_connect('localhost','mysql_username','mysql_password'); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db('databasename'); ?>[/code] the first thing we do here, is: Open a connection to the mysql server. If the connection failed, the code will write an error then, we select the database we want to use. If you find anything spelled wrong, or any code that I wrote, that is wrong, or if you find something that is not working as it should, paste the wrong word(s) or the wrong code(s) or the error(s), and I'll fix them. Regards //Feelay You are not allowed to copy anything from this tutorial, and paste it outside of this topic, without my permission. But you are allowed to copy/paste parts of it, inside this topic.
Sun May 25, 2008
Reply New Discussion
Posted in Computers & Tech / Software / Internet & Network Clients..
Author: Feelay Total-Replies: 6 Hey! I am having a small problem in firefox on my website. When the user is logged out, the website looks wacked :S But in Internet Explorer it works just fine =( I can't exactly explain what the fault is, because I don't know it myself, but can you please try to look? Here it is.. Sorry if this is wrong forum, but I thougt that it had something with the Internet to do.
Sun Feb 24, 2008
Reply New Discussion
Posted in Computers & Tech / Programming / Game Programming
Author: FirefoxRocks Total-Replies: 2 I would like to design a turn-based game like http://x-kings.com/. I think I can do it with HTML, PHP and MySQL, but how do I get started? How should I plan out the game before I start any coding? Any tips would be appreciated.
Tue Jul 27, 2010
Reply New Discussion
Posted in Computers & Tech / How-To's and Tutorials / Programming / PHP
Author: Feelay Total-Replies: 42 Hey! Today, I am going to teach you how to make a Private Message (PM) script in PHP. Before we start, I want to tell you what you should know, and what files we will create. Then we will continue with the codes, and descriptions. I would like if you learned something from this tutorial. If you find any errors (Even if I spell something wrong), I would like you to post it in this thread. What you should know: You should know HTML. Just a bit (forms, and maybe a little design if you would like that). You should know much about PHP and Mysql. You should know how to create a login-script, because you will need it for this tutorial. if you don't know how to create one, you can check a very simple login-script tutorial that I made some time ago: How to create a login-script Now.. Lets start with the Mysql table, or? Thanks to Vujsa I could make this one messages.SQL [code]CREATE TABLE `messages` ( `message_id` int(11) NOT NULL auto_increment, `from_user` varchar(65) character set latin1 collate latin1_general_ci NOT NULL, `to_user` varchar(65) character set latin1 collate latin1_general_ci NOT NULL, `message_title` varchar(65) NOT NULL, `message_contents` longtext NOT NULL, `message_read` int(11) NOT NULL default '0', PRIMARY KEY (`message_id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=21;[/code] The things we have done here is: We have created a table named 'messages'. then we have created some columns: message_id : This is the column where the ID of the message will be stored. we will need this when we will get the messages from the table. from_user : This is the column where the name of user that sent the message will be stored. to_user : This is the column where the name of the user that the message was sent to is stored. message_title : This is where the title of the message will be stored. message_contents: This is where the content of the message will be stored. message_read : This will check if the message id read or not. Save this in a file and call it "messages.SQL" or something. Now after you have created the table (if you don't know how to import SQL files, you should go and learn You should start with the inbox file. inbox.php [code]<?php session_start(); require "database.php"; $userfinal=$_SESSION['session_name']; // get the messages from the table. $get_messages = mysql_query("SELECT message_id FROM messages WHERE to_user='$userfinal' ORDER BY message_id DESC") or die(mysql_error()); $get_messages2 = mysql_query("SELECT * FROM messages WHERE to_user='$userfinal' ORDER BY message_id DESC") or die(mysql_error()); $num_messages = mysql_num_rows($get_messages); // display each message title, with a link to their content echo '<ul>'; for($count = 1; $count <= $num_messages; $count++) { $row = mysql_fetch_array($get_messages2); //if the message is not read, show "(new)" after the title, else, just show the title. if($row['message_read'] == 0) { echo '<a href="read_message.php?messageid=' . $row['message_id'] . '">' . $row['message_title'] . '</a>(New)<br>'; }else{ echo '<a href="read_message.php?messageid=' . $row['message_id'] . '">' . $row['message_title'] . '</a><br>'; }} echo '</ul>'; echo '<form name="newmsgfrm" method="post" action="new_message.php">'; echo '<input type="submit" value="Send a New Message">'; echo '</form>'; echo '<form name="backfrm" method="post" action="index.php">'; echo '<input type="submit" value="Back to Home">'; echo '</form>'; ?>[/code] simple isn't it? The first things we do are very simple. We start the session. We require the database.php file (the database.php is the file where the mysql connections and stuff is stored. you should know how to created such a file. if you don't know, i'll create one in the end of this tutorial, only for you then we create a variable for the set session, to make it easier to write. Then we create some variables. the $get_messages is the variable where the message id is stored. the $get_messages2 is the variable where all the messageinfo is stored. Then we create a simple for-loop that will show all the messages that is sent to the user that is logged in(check w3schools or google or whatever, if you don't know what that is.). the first thing we do here is: Check if the message is read. If it isn't, the loop will add "(new)" after the message title. else, it will just show the message title. The last thing we do is: Add 2 buttons. One to send a new message, and one to go back to the home-page. Now lets begin with the new message file. new_message.php [code]<?php session_start(); require "database.php"; $userfinal=$_SESSION['session_name']; $user=$userfinal; ?> <form name="message" action="messageck.php" method="post"> <input type="text" name="message_title"> Title: <br> <input type="text" name="message_to"> To: <br> Message: <br> <textarea rows="20" cols="50" name="message_content"> </textarea> <?php echo '<input type="hidden" name="message_from" value="'.$user.'"><br>'; ?> <input type="submit" value="Submit"> </form>[/code] The things we do here, are also very simple. The first things we do is: Start the session. require the database.php file. create a variable for the set session. then we create the forms. a textbox for the message title. a textbox where you write to who you want to send the message. a textbox for the message content. and then, you see this line: <input type="hidden" name="message_from" value="'.$user.'"> This is a hidden line, and the user will not see it. this invisible textbox, includes the name of the user that is writing the message. remember that we created a variable named $user that includes the session name? the session name, includes the username. and where the "value" is "$user", the username is inserted by the code. then we create a normal submit box, that will send the message, and we are done with this file. Now we should create a file, that checks if the sent message is ok to send. messageck.php [code]<?php session_start(); require "database.php"; $title=$_POST['message_title']; $to=$_POST['message_to']; $content=$_POST['message_content']; $from=$_POST['message_from']; $time=$_POST['message_date']; $ck_reciever = "SELECT username FROM user WHERE username = '".$to."'"; if( mysql_num_rows( mysql_query( $ck_reciever ) ) == 0 ){ die("The user you are trying to contact don't excist. Please go back and try again.<br> <form name=\"back\" action=\"new_message.php\" method=\"post\"> <input type=\"submit\" value=\"Try Again\"> </form> "); } elseif(strlen($content) < 1){ die("Your can't send an empty message!<br> <form name=\"back\" action=\"new_message.php\" method=\"post\"> <input type=\"submit\" value=\"Try Again\"> </form> "); } elseif(strlen($title) < 1){ die("You must have a Title!<br> <form name=\"back\" action=\"new_message.php\" method=\"post\"> <input type=\"submit\" value=\"Try Again\"> </form> "); }else{ mysql_query("INSERT INTO messages (from_user, to_user, message_title, message_contents, message_date) VALUES ('$from','$to','$title','$content','$time')") OR die("Could not send the message: <br>".mysql_error()); echo "The Message Was Successfully Sent!"; ?> <form name="back" action="inbox.php" method="post"> <input type="submit" value="Back to The Inbox"> </form> <?php } ?>[/code] now you guys should know the first things we do (starting a session and including the database file.). Now the second thing we do in this script is creating a variable for every single form in the last script. We create a variable for the message title, content, "to-user" and so on. We do also create a variable that selects the username that was set in the "to-user" form. Then we create a if-statement that checks if the user excists. If not, the code will write an error message, and show you a back-button. Then it will check if there is any content and title. If not, an error message will be written, and a back-button will be shown. Else if everything worked as it should work, the message will be inserted in the database table that we created earlier. Now we should create a file that will let the user read the message, or read_message.php [code]<?php session_start(); $userfinal=$_SESSION['session_name']; require "database.php"; $messageid = $_GET['message']; $message = mysql_query("SELECT * FROM messages WHERE message_id = '$message_id' AND to_user = '$userfinal'"); $message=mysql_fetch_assoc($message); echo "<h1>Title: ".$message['message_title']."</h1><br><br>"; echo "<h3>From: ".$message['from_user']."<br><br></h3>"; echo "<h3>Message: <br>".$message['message_contents']."<br></h3>"; echo '<form name="backfrm" method="post" action="inbox.php">'; echo '<input type="submit" value="Back to Inbox">'; echo '</form>'; ?>[/code] you know the first things we do here. the second things I do is creating a variable that includes the value from the"<a href="read_message.php?messageid=' . $row['message_id'] . '">" in the inbox file. then I create a variable that will include all the info about the message with that id (and check if the post is sent to the user or not [If it isn't, the post will be empty, else, the contents will be shown]). then I create three echos. The first one will write the title of the message. the second one will write the name of the user that sent the message. the last one will write the content of the message. then I just add a back-button. simple isn't it? now for those of you who don't know how to make a database.php file, here it is, but I won't comment it. database.php [code]<?php mysql_connect ("localhost", "mysql_username", "mysql_password") or die ('I cannot connect to the database because: ' . mysql_error()); mysql_select_db ("db_name"); ?>[/code] Remember! If you find any errors, post them here, and I will try to fix them as soon as possible. I have tryed this PM system, and it works! Thanks for reading! //Feelay
Wed Mar 12, 2008
Reply New Discussion
Posted in Computers & Tech / Software / Content Management Systems (CM.. / PHP-Nuke
Author: Houdini Total-Replies: 7 For those that like the IPB forums and want to use PHP-Nuke a standard PHP_nuke comes with the phpBB forums, but I have a modified version that you can download and use. This modified version comes with only one language supported (English) but you can add them if you want. When uploaded to your server it occupies about 8.5 Meg and loads quickly. NOTE IPB forums do not come with the program due to licensing requirements. So you have to have your own copy of IPB. The site is IPB Nuke and the download is IPB Nuke download Note also if you go to the Forums on the site that I have modified the bb codes on it...your bbcodes will be the standard boring grey buttons just like on this site.
Thu Jun 9, 2005
Reply New Discussion
Posted in Computers & Tech / Software / Content Management Systems (CM..
Author: Alexandre Cisneiros Total-Replies: 5 Hi! I'm here to ask your opinion: I'm going to create my CMS based on PHP (i isn't named yet) and i what you thing that is more important. Please answer this questions: Multilingual Suport: -With Languages? Features: -Forums? -Downloads? -Blog? -User account? -Or just it comes with User account and the user who wants download the separetad modules? Templates: -If you download a CMS, you prefer to download it with only the default template and get separated templates, or download with many (3-8) templates? Database: -MySQL? -PostgreeSQL? -Other database? -Many databases? Others: -Leave sugestions, please! If you can help-me, please reply this topic.
Sun Jan 29, 2006
Reply New Discussion
Posted in Computers & Tech / Programming / Scripting / PHP
Author: vujsa Total-Replies: 8 So I need help getting data entered into my log correctly. I want the newest entry to be at the beginning (top) of the log instead of at the end (bottom). Here's what I have: [code]<?php function access_log(){ // Enter data in usage log. $filename = "access.log"; $entry = gmdate("M d, Y H:i:s T").": ". getenv("REMOTE_ADDR").": ". getenv("HTTP_USER_AGENT")." \n"; fwrite(fopen($filename, "a"), $entry); fclose(fopen($filename, "a")); } // End function access_log() ?>[/code] And it outputs: Mar 29, 2005 07:57:16 GMT Standard Time: 192.168.1.1: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.2) Gecko/20040804 Netscape/7.2 (ax) Mar 29, 2005 07:57:40 GMT Standard Time: 192.168.1.1: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.2) Gecko/20040804 Netscape/7.2 (ax) Mar 29, 2005 07:58:03 GMT Standard Time: 192.168.1.1: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.2) Gecko/20040804 Netscape/7.2 (ax) Mar 29, 2005 08:02:01 GMT Standard Time: 192.168.1.1: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.2) Gecko/20040804 Netscape/7.2 (ax) Mar 29, 2005 08:02:04 GMT Standard Time: 192.168.1.1: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.2) Gecko/20040804 Netscape/7.2 (ax) Mar 29, 2005 08:02:07 GMT Standard Time: 192.168.1.1: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.2) Gecko/20040804 Netscape/7.2 (ax) Mar 29, 2005 08:02:09 GMT Standard Time: 192.168.1.1: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.2) Gecko/20040804 Netscape/7.2 (ax) Notice how the newest entry is at the bottom. I need the data to read like this: Mar 29, 2005 08:02:09 GMT Standard Time: 192.168.1.1: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.2) Gecko/20040804 Netscape/7.2 (ax) Mar 29, 2005 08:02:07 GMT Standard Time: 192.168.1.1: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.2) Gecko/20040804 Netscape/7.2 (ax) Mar 29, 2005 08:02:04 GMT Standard Time: 192.168.1.1: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.2) Gecko/20040804 Netscape/7.2 (ax) Mar 29, 2005 08:02:01 GMT Standard Time: 192.168.1.1: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.2) Gecko/20040804 Netscape/7.2 (ax) Mar 29, 2005 07:58:03 GMT Standard Time: 192.168.1.1: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.2) Gecko/20040804 Netscape/7.2 (ax) Mar 29, 2005 07:57:40 GMT Standard Time: 192.168.1.1: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.2) Gecko/20040804 Netscape/7.2 (ax) Mar 29, 2005 07:57:16 GMT Standard Time: 192.168.1.1: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.2) Gecko/20040804 Netscape/7.2 (ax) I've tried:[code]fwrite(fopen($filename, "r+"), $entry);[/code]Set pointer to the beginning. But that erases the first line when a new entery is added. Please let me know how to adjust the code to insert an entry at the beginning. Thanks, vujsa
Tue Mar 29, 2005
Reply New Discussion
Posted in Computers & Tech / Internet and Websites
Author: Xarex Total-Replies: 19 So it took me a while to find a CMS that suited my needs. I was into website design many years ago, in my teens, and left it, as I really had no good ideas for a website then. I am now older and had an amazing idea for a website and decided to just go with it. My website is a psychedelic music blog. Everyone can come and read the articles, blog about their new or existing favorite artists, post on the forums, chat, submit, and watch videos and participate in the occasional site contest/game. So a friend helped me make this idea a reality by showing me the world of PHP & CMS, which I had no idea existed. I'm now 3 months into it and have learned quite a bit. Though I have only tried out a few before stumbling upon a CMS that really fit my needs. He started me off with PHP Fusion. It was great. I could easily customize it, found just about every plugin I needed, and had everything set up and working great. Problem was... too many bugs. Many of my visitors had trouble registering, logging in, and the "infusions" (plugins) themselves were also quite buggy. I had learned PHP quite easily and made many changes to the existing code to make it work for my site. Everything was great, but I really wasn't satisfied. PHP Fusion also seemed to display errors to my visitors without really saying why.. such as a blank, white, or black page that wouldn't do anything. So I left PHP Fusion. I won't knock PHP Fusion.. it got me started, it has its uses but I think once you want your site to have much more advanced features, PHP Fusion can only go so far. I moved on to WordPress. But WordPress is really just a blogger with a lot of plugins to enhance it, and I was looking for more than just a blogger and more than just people being able to view videos, register, and comment. So I won't knock WordPress for its most basic use. However, I attempted to customize WordPress, I added BuddyPress and a few other plugins hoping to make a kind of Social Network, but soon after adding the Addons, the pages got corrupt and I couldn't even load it. I attempted to do it again -- this time installing one plugin at a time, only to run into the same problem again. So while there are literally hundreds to probably thousands of plugins, many are quite buggy and probably should have never been made, or at least been coded to work better with WordPress. After WordPress, I was looking for another one. I came across a site similar to what I wanted. So I emailed the designer of the site and asked him how much it would cost to make a site like his. He told me he used Joomla and the exact plugin. So I installed Joomla and since Joomla is out with a new version, there are not as many newer plugins for the new version - or at least at the time, there wasn't, but I read about a plugin that makes old plugins work. I attempted to install it but I couldn't find it for some reason. That kind of cut out a lot of the plugins that I was hoping to use for my site. So I logged on to the plugin site he sent me, and the only difference in the site was that the theme was changed, but everything else was just that same plugin -- so it seemed very commercial to me. I also noticed that, although his site was definitely very beautiful in design and does attract a member base, there just seemed to be something that put me off about it. So again, I won't knock Joomla. But it just didn't seem to be cut out for my needs, or at least, it seemed like it was going to take too much time to try and get everything to work. I haven't tried Drupal out yet but have read the pros and cons. So I won't knock any CMS but there are some that work for people and some that don't. It all depends on what you want your site to do and how you want to interact with your guests. I ended up redesigining my site completely after going with a CMS called ocPortal. This CMS was like a dream come true.. it offered everything I was looking for - chat, built-in forums, blog, photo and video gallery, shoutbox, easy-to-use & setup navigation/menu bar, and even games. So the features I'm using and needed:
There are tons more features that you can read here including e-Commerce and Ticket Support: http://ocportal.com/site/features.htm It was quite overwhelming at first to learn and it certainly has scared away quite a few people, but once you get past the little learning curve, it truly is an amazing CMS that works pretty much right out of the box and comes with everything you need. Other than the addons that are already offered, there really doesn't seem to be a need for much more than that. I've read pros and cons.. pros being that it works out of the box, it's small, fast, etc. And the cons being that there aren't many themes and that the support community is small. But themeing is fairly easy after reading through "Jean's Tutorial." And also, despite there being a small community, you get individualized attention and support from the programmers themselves, among with many others who have remained loyal to the ocPortal CMS. Of course, I have become quite loyal to this CMS as well, because I was able to get a fully functioning website up that I wanted to display to my visitors. But I am always looking for just-as-good or better, to always improve my own site design and code to make the least buggy most efficient systems to my visitors. I am still working on little side projects such as a video section that is more like YouTube -- you can view that here: http://www.youtrippy.com/videos (not currently being used for the public) You can view my website at: http://www.youtrippy.com So if you've come across a CMS that has really worked for you. Please list the following information:
Tue May 24, 2011
Reply New Discussion
Posted in Computers & Tech / Software / Bulletin Board Systems
Author: Zac Total-Replies: 5 The following was taken from the Invisionfree.com Support Boards. http://support.invisionfree.com/index.php?showtopic=241452 QUOTEInvisionFree is proud to officially announce ZetaBoards™ (what has previously been referred to as InvisionFree 2).![]() The ZetaBoards software will be a full upgrade for InvisionFree. It already has gone through thousands of hours of design and development. While it is designed to be familiar to current InvisionFree users, it will have hundreds of new features. Nearly every aspect of InvisionFree will be improved: from the PM system, to the admin logs, to security, to attachments. Administrators will find their tasks much easier and faster to perform. New members will have an easier time learning how to use your board. Experienced members will also find many useful new features in our software. ZetaBoards is intended to offer the benefits found normally with self-hosted forums in the ease of a remotely hosted free environment. ZetaBoards software has been designed from the ground up to allow multiple forums to run easily on the same server. Your remotely hosted board will be able to have a wide variety of modifications easily installed to personalize it. As we approach the release of the ZetaBoards software we will be providing screenshots and details on some of the new features. We will be upgrading the support board and providing a test board for members to get acquainted with before upgrading all boards. You will be able to opt out of the upgrade if you are not comfortable with an immediate change. Since the name InvisionFree would not fit the new software, we will be changing our name to ZetaBoards. Both URLs will still work, so the transition will be easy. We will guide you through the URL change process and the upgrade to the new ZetaBoards forum software. We will still be a free service. You will not lose your board in the upgrade. The upgrade will be done to all InvisionFree boards for free, without any required work on your part. We look forward to many more years of hosting with you! I think that this project is a great idea for Invisionfree or Zetaboards™ to get in to the dicussion board market. Ever since Invision Power Board said they couldn't use IPB 2.0 without a liscense for everyboard, I thinl everyone knew this would happen. What are your thoughts on this?
Thu Jun 22, 2006
Reply New Discussion
Posted in Computers & Tech / How-To's and Tutorials / Programming / PHP
Author: 8ennett Total-Replies: 8 Before starting on this tutorial be sure to run through the first 4. Part 1: Advanced User Account System Part 2: Welcome Home Part 3: Administrative Part 4: Profiles ######################## Part 5: Messaging & Inventory ######################## Download Example5.rar Now this tutorial is going to cover quite a lot. I thought I'd best pick up the pace so you can get learning in larger chunks now you are starting to understand the code. In this tutorial we are going to introduce a few new things, such as cron jobs and javascript. Also you will notice I have changed the design of the example site. Here is a list of all the features added in this next tutorial. Messaging System
First of all it turns off the server, logging everyone out so it can run through quickly without causing drag on the server and offers an equal chance to all players for our dailies (which we haven't got any of yet). Next it decides randomly how much strength and defense to take off each player. As with real life, players will need to maintain their training (in the gym we haven't built yet) otherwise their stats will go down. This is another form of evening the playing field. It would be unfair if someone who was new to playing going against a player who hasn't been on in a long time but has started playing again. After this we delete all the item prices for yesterday and change the current days prices to 2 which means yesterday. Then we can loop through and create the new prices for the new day for each item. It creates the new price by creating a random figure between 90% and 110% of the items average price. So if you create an item with an average price of $100, then the new days price would be between $90 and $110. This helps to prevent the market from getting stagnant and encourages players to buy large quantities of goods and hold them until they can sell them again for a profit. Next up, the cron job we switch the server back on so people can log back in again and start playing the new day. We will need to put our crons in a place where they can't be accessed by anyone who visits your site, so putting them in your root directory in a file named crons so you can simply type in http://www.mysite.com/crons/five.php to refill your health wouldn't be advisable. Instead put them outside your public_html directory (also htdocs, www depending on your server). So create a new folder outside your public_html folder named crons and place the day.php and five.php documents in the archive in to this directory. Next edit line 3 in five.php and lines 3 and 43 in day.php to point towards your config file. So on an astahost server you would change this to '../public_html/lib/config.php'. I'll show you how to get the cron running on cPanel X on astahost. First of all you need to open the cron jobs section and create two new crons. Here is how each should be configured:
Daily Cron
Minute = 0 Hour = 0 Day = * Month = * Weekday = * Command: php /home/mysite/Crons/day.php
Five Minute Cron
Minute = */5 Hour = * Day = * Month = * Weekday = * Command: php /home/mysite/Crons/five.php Each of these crons should now run both daily and every five minutes. You can try them out by editing the database to reduce your health and energy and watch them increase every 5th minute. Next up we have our messaging system. For this we created a new folder in the modules directory called inbox and also inserted a new menu item for the inbox as well. We have also created a new feature for a menu item where if the user has unread email in his/her inbox then it will be displayed next to the link as shown below.
This image shows the inbox displaying messages in ascending order from the date they were received, however I have changed this to descending so the newest is on the top of the list. So we have our list of messages in our inbox. We are able to open these messages by clicking the subject or delete these messages by clicking on the X next to them. We can also create a new message, there is another button for turning off/on our inbox and choose who we accept messages from. Click the "Accept Messages From Anyone" button will change your inbox settings and the button will change to "Accept Messages From Friends Only".
Below is what is displayed if we click on a messages subject.
So here we have a display of our message. The date and time, a clickable link with the senders name, the subject, the messages content (with full bbcode processing) and our message controls. Clicking the "Mark as Unread" button will take us back to the inbox and obviously mark our message as unread. "Delete" deletes it and etc. Now if we click on the reply button this will take us to the same page as the "Compose New" button in the inbox however the users id field has already been filled in.
Also, there is a new button on the user profile page called "Send Message" which also fills in the user id field. So here we have our message creation system. We can write our bbcode as well as our message in to the message field. Now our subject field is fairly interesting, if we are replying to a message it will add "Re:" however if the message subject already contains "Re:" or any variation it will remove these first then add its own "Re:" to prevent message subjects from becoming something like "Re: Re: Re: Re: Just another example".
Here we have our events list found on the menu. This is subject to the same tests as the inbox link where a box is displayed with the amount of new events eg. [5 new]. So when ever a user has had some interaction with your account we can send the user an event alert to let them know what it is. Now as you can see above we also have a clear events button. This will delete any and all events the user has had. Like the emails however, this will not actually delete them but instead set the status to deleted so admins are able to view everything before it is deleted from the server. We haven't written in to the cron to delete messages or events over a a certain amount of time, I thought I needed to break this process up a bit as this is quite an extensive part of the tutorial already. Another feature of the events list is listing our events in pages. If there are more than 10 events then a button will be displayed saying next page, this takes us back to this page but with the $_GET['page'] variable set. If this variable is more than 1 then a previous page button is displayed. Next we can move on to the inventory system.
So here we have five different types of items. Weapon, Armour, Consumable, Drug and Other. Each item has its own options (although drugs and other are the same for now) which for now are hard coded in to the inventory.php file in the modules directory. Each item has several values in the database numbered 1-5. These will have different effects depending on the item type but this will be explained in the admin item editor later. So you can see we can equip our weapons and armour which will place them in the equipped armour and weapon slots at the top. We can also unequip them. Another thing we have to remember is if we have an item equipped but then we sell it, we will then have to unequip that item as well. Clicking each items image will open a pop-up window containing all the information about the item except current and previous prices.
So the values listed in the database each have their own property for a consumable item as show above. It also displays the average price of the item, although the current price could be anywhere from 90% to 110% of this items average price. We may later want to create items that get us out of hospital faster, prison or some other thing but this will be covered in another tutorial. So if we choose to sell an item we will see this.
So like we covered earlier, you can see todays price and yesterdays price with arrows letting us know the difference more easily. Ok moving on to sending an item to a person.
So here we have our live search example. By entering a full or partial users name in the input field a list of results (up to 10 max) will be displayed underneath. Clicking one of these names will complete the input field allowing you to send the item. This will also to check to make sure the users inventory is not full. Another check that is performed during the transfer is wether or not the user sending the item has the same last ip as the user receiving the item. If so we then check to see if both user accounts use the same password. If not then it is not likely the user accounts are owned by the same user and so an alert is put in to the admin inbox (both users might just be on the same network) and then the admin can decide if they want to ban the accounts or not. If the passwords do match then the accounts are both automatically disabled for 6 months and the user will be logged out. An alert will also be sent to the admin inbox (which we are yet to build) if this happens. So that is the basics of our inventory system. Next we need a way to create and edit items. Now we have our new game editors button on the admin panel and two new editors. We can either edit and create new items or send created items to different users.
So as stated earlier, when we are creating a new item and change the item type, it also changes the values 1-5 input fields using javascript.
Also the new item will not be created unless a valid image has been selected to upload as well. Now I have included five items to get you started, also I have given you a template item image which is just the green background. You can find it in images/inventory/template.png. Now when we select an item to edit we see the below screen. Changing the items type will change the fields the same as creating a new item. You can also choose to delete the item or upload a new image. If you make changes to the item but do not select a new image then the old one will stay the same. Next we have the send item option. This merely sends whatever item you choose to a user and inputs an alert in to that users events. There is also another link on a users profile for admins sending items to users and automatically fills in the user id field using the $_GET variable. The admin control panel will appear on a users profile if you are an admin or a super admin (obviously). So I think that's about all covered in this next part. As usual leave any comments or questions. Also sorry about having to post some of the images links instead of images but the forum won't allow too many images.
Mon Jan 24, 2011
Reply New Discussion
Posted in Computers & Tech / How-To's and Tutorials / Programming / PHP
Author: 8ennett Total-Replies: 6 This tutorial will demonstrate how to create a chat application for your website using PHP and MySQL . The application will allow the user to select a username and to enter messages that will be displayed for another user to read. First of all you will need to create a MySQL table which will store the username, user id, and the messages body. Copy the following MySQL query and paste it in your MySQL editor or console: CREATE TABLE IF NOT EXISTS `chat` ( `userid` int(10) UNSIGNED auto_increment, `nick` varchar(10) NOT NULL, `text` varchar(100) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; After creating run the next MySQL query to insert our initial values as a test: INSERT INTO `chat` (`userid`, `nick`, 'text') VALUES (0, 'Bennett', 'Hello World'); Now Bennett is the default user who can log in and send more messages. You can also use this method to create more users. I will run you through how each of the following PHP files work:: To display the messages we need to create a view which will store the last valid records (you can develop your own logic), as follows: create view msg as (select * from chat where userid not in (1,2,3) and text <> '' order by userid desc limit 5); In the above code select * will fetch each and every value which not comes in 1,2, or 3 (let's consider these values will be reserved for actual users) , whenever you login an unwanted message as "user: "could generate to prevent from this kind of situation we need to write text<>'', we need to write userid desc limit 5 to display last five messages. We are assuming several things here as this is just a demo of the chat system. You can later develop these files to suit your own needs. Now create a PHP document called 'chat.php' and copy and paste the following code in to it: [codebox]<?php session_start(); ?> <html> <head> <script type="text/javascript"> function nick() { var nick=document.chat.user.value; res=true; if(nick=="") { alert("please enter a value"); //document.tchat.nick.focus(); res= false; } return res; } </script> </head> <body> <center> <form name="chat" action="<?php echo $PHP_SELF;?>" method="post" onsubmit="return (nick())"> <input type="text" name="user" ></input> <input type="hidden" name="action" value="enter"></input> <input type="hidden" name="chat" value="" ></input> <input type="submit" value="submit"></input> </form> </center> <?php $link=mysql_connect("localhost","root",""); if(!($link)) { die("Can not connect". mysql_error()); } mysql_select_db("Bennett", $link); $result=mysql_query("select * from chat"); $nick="hello"; if(isset($_POST["user"])) $nick=$_POST["user"]; while( $row=mysql_fetch_array($result)){ $rownick= $row['nick']; if($rownick==$nick){ $_SESSION['view']=$nick; echo $_SESSION['view']; //echo "Hello ". $_SESSION['view']; header("location:chatroom.php"); } } ?> </body> </html>[/codebox] Next we want to create a new PHP document called chatroom.php and copy and paste the following code in to it: [codebox]<?php session_start(); if(isset($_SESSION['view'])) $nick=$_SESSION['view']; $MSG=""; if(isset($POST['msg'])) $MSG=$_POST['msg']; ?> <frameset rows="50%,24%"> <frame src="msgDisplay.php" /> <frame src="msgInput.php" /> </frameset> <noframes> <body> Your browser doesnot support frames </body> </noframes>[/codebox] Next create a PHP document called msgInput.php and copy and paste the following code: [codebox]<script type="text/javascript"> function message(){ result=true; mesg=document.msg.msg.value; if(mesg==""){ alert("Please fill any message"); result= false; } return result; } </script> <?php session_start(); $user=""; if(isset($_SESSION["view"])) $user=$_SESSION["view"]; $MSG=""; if(isset($_POST['msg'])) $MSG=$_POST['msg']; $link; $link=mysql_connect("localhost","root",""); if(!($link)){ die("Could not connect".mysql_error()); } mysql_select_db("Bennett",$link)or die("Can not connect".mysql_error()); $result=mysql_query("insert into chat values (0,'$user','$MSG')"); ?> <form name="msg" method="post" action="<?php $PHP_SELF;?>" onsubmit="return message()"> <input type='text' name='msg'></input> <input type="submit" value="submit"></input> <a href="Logout.php" target="_top">Log me out</a> </form>[/codebox] Now create another PHP document called msgDisplay.php and copy and paste the following: [codebox]<meta HTTP-EQUIV="Refresh" CONTENT="2"></meta> <?php session_start(); if(isset($_SESSION['user'])) echo $_SESSION['user']; $link=mysql_connect("localhost","root",""); if(!$link){ die("Error".mysql_error()); } else { mysql_select_db("Bennett",$link); $query=mysql_query("select * from msg order by userid"); while($row=mysql_fetch_array($query)){ echo $row['nick'].":".$row['text']."<br/>"; } } ?>[/codebox] Create another document called Logout.php then copy and paste the following: [codebox]<center><b><u>You are successfully logged out</u></b></center> <?php session_start(); session_unset(); session_destroy(); ?> <a href="chat.php"> log me in</a> <?php $link=mysql_connect("localhost","root",""); if(!$link){ die("Error".mysql_error()); } mysql_select_db("Bennett",$link); mysql_query("delete from chat where userid not in (130,131,132)"); ?>[/codebox] Output: First web page will look like: ![]() If you forget to type anything, and hit the submit button: ![]() If the username is valid then next web page will look like: ![]() Enter any text and it'll display on the upper frame, here varun is an user: ![]() If you don't enter any text and hit submit button, alert message will display that: ![]() After successfully logged out next page will be look like: ![]() Full code of the chat system is provided in the following .rar file. The source code of chat application.
Mon Feb 1, 2010
Reply New Discussion
Posted in Computers & Tech / Programming / Scripting / PHP
Author: 8ennett Total-Replies: 2 Just had a thought for tracking copies of my php game engine online ina hidden way. Basically I've already had people taking PGE and intending to convert the source code in to a premium game instead which requires a license to do. I need a way to track all copies of my engine online. I don't really want to have some form of online database used to operate the engine because that would cost me a lot in bandwidth. My thoughts were to conceal certain data in the page headers and source code then use a search engine to search through source code instead of browser output but it keeps bringing me round to code search instead which isn't what i'm after. Anyone got any thoughts on how to do this? Obviously it can't be too obvious otherwise people could null it out, but i've got ideas and methods to disable a script after i've found one running premium without a license.
Sat May 28, 2011
Reply New Discussion
Posted in Computers & Tech / Programming / Scripting / PHP
Author: daniel15 Total-Replies: 16 I'm just interested to know how many people here know PHP. Please reply and say if you use it, what you use it for, etc.....
Fri Sep 24, 2004
Reply New Discussion
Posted in Computers & Tech / Programming / Scripting / Perl & CGI
Author: ajmal Total-Replies: 21 Use PHP. I have a beta login script that I coded some time ago, it's supports registering, email activation, access levels and etc. I spent 2 days coding it only, it's not that hard, just be patient. you need, besides the html, obviously a script that handles the posted data, compares the login info and etc.
Thu Aug 18, 2005
Reply New Discussion
Posted in Computers & Tech / Programming / Scripting / PHP
Author: Jimmy89 Total-Replies: 5 Hi all, I have a friend who, for his extended IT project is interested in making a website partly out of php. When he asked for advice my first thought was here. I would like to know some good websites, tutorials etc that he can use to introduce himself to php (he hasn't done much before). He is interested in making a simple login/subscription service where you can signup and then login to a 'members only' page. Any ideas and code samples that you have to share would be greatly appreciated. Thanks, -jimmy [note=BuffaloHELP]Jimmy, you need to work on making topic title very specific.[/note]
Mon Jul 2, 2007
Reply New Discussion
|