A basic login logout system with session

Category : PHP Programming     Tags : php   script   tutorial    

This is a very simple Login/Logout system script which uses session. It only uses 1 set of username and password which is set in the php script. I hope you could get some idea on how a login/logout system basically work.
Just copy and paste the php script below and test it yourself.

PHP Code

<? session_start();

$do=$_GET["do"];

if($_POST)
{
if($_POST["name"]=='admin' && $_POST["pass"]='pass')
{
$_SESSION["username"]='Admin';
}
}

if($do=='logout')
{
session_destroy();
unset($_SESSION["username"]);
}
?>

<html>
<head>
<title>A Sample Login Script | PHPGame.Net</title>
</head>
<body>
// ======== IF LOGIN SESSION NOT EXIST-REQUEST TO LOGIN
if(!$_SESSION["username"] && $do!='logout')
{
print " Your are currently not login.<br/>Please login with your username and password below
<form action='' method='post'>
Username <input type='text' name='name' size='20'/> (admin).<br/>
Password <input type='password' name='pass' size='20'/> (pass).<br/>
<input type='submit' value= ' Login '/>
</form>";
}

// ======== LOGOUT
if($do=='logout')
{
print "You have successfully logout.<br/>
<a href='index.php'>Click here to main page</a>";
}

// ======== LOGIN SESSION EXIST-YOU CAN ONY SEE THIS AREA ONCE YOU LOGIN CORRECTLY
if($_SESSION["username"])
{
print "Welcome to the Admin area<br/><br/>
<a href='?do=logout'>Logout now</a>";
}
?>
</body>
</html>



Intro How to make a Web Game

Category : How to make web game     Tags : mmog   pbbg   tutorial    

I believe you are just another one out of thousands web game fans out there who are eventually wanted to make your own web game. Making you own web game and running it online is indeed fun and is more challenging than playing some web games itself.
But before I would even touch the topic 'How to make a web game', I just wanted to know how much you would willing to sacrifice onto such project? Not in terms of money but I mean in terms of time and effort. 1 month, 3 months, 6 months or 1 years?
Making a web game is a big project, eventhough if it was only a simple web game with a few basic functions. It would takes months of time just for the preparation and another few months to do the programming, debugging, testing and balancing before it could be put into real test. Unless you are really good in web programming or have a team of professionals for the project, you ain't going to have a web game within a couple of months time.

So, you got to have abundance of time(several months or even years), really hardworking and are very passionate about making your own web game. Otherwise, just get on with your life playing web games instead.

Still Eager to make a web game?
OK, assuming you know nothing about making web site and programming. You just have no clues what to do and where to start building your web game project and yeah, you've got the time!
This is what you should do;
Forget about php programming and learn HTML and CSS to make a static web page. You shouldn't run when you can't even walk. Start from the basic!

Learning HTML and CSS
You don't need any special program or software to do this, just use the notepad (for windows pc) available on your computer and start hand coding a webpage using HTML tags and some CSS. You may find it troublesome to hand code a webpage at first but when you go further down to PHP programming, it would even takes more hand coding job. Your objective now is to make a web page template of the web game you wanted to do, just imagine how you want the main page of your web game to look like.
There is a whole list of websites out there where you could get tutorial about HTML and CSS for free. w3school is a good website with extensive tutorials for all web programming language.

Also, you would like to participate on some webmastering community discussion to learn more and ask question when you run into any problem.
HTMLForums is a good webmastering community forums to discuss about everything you need to become a webmaster.

Document your web game project.
I'm sure you already have some idea of what kind of web game you wanted to make. So, get the pen and paper and start document your project. Jot down all the information and details about the game. Draw some images or interface of every function of the game.

A good detalied game document would ensure you to have a smooth work during the game programming phase. If you think you could just rely on those idea in your brain and get on with the programming without document then that would be something really really bad. That is what exactly I did when I firstly developing my own web game. The idea in my brain seems perfectly nice that I jump into programming instantly. Everything seems to be functioning accordingly but eventually those ideas in my brain got depleted, and my game is still not completed!
I tried to think and think and think for new ideas but it end up with a lots of modification and re-programming work and somehow, I dropped the the game.
So, don't start progamming a game until you have prepared enough detailed information about the game.

Get started with PHP
As you started to learn PHP programming, you need to install a server environment on your computer in order to execute the PHP files. There are many easy installer program out there which could do the job with only a few simple steps.
XAMPP
EasyPHP
WAMP

Once you have installed the web server program on your computer, you can start executing php scripts from your computer as well as managing your MySQL database to develop your project.

MySQL
While PHP acts as your dynamic script in executing functions and producing output to the end user, MySQL is a database program. You need to have a database to keep all kind of information in your game such as accounts information, characters, weapons and so on. All server program comes with phpmyadmin which is used to manage your database.

As you learn up more and more PHP functions, you could start to do a few simple php function such as creating a login system with the integration of MySQL database, an account signup system and so on before you could get into your game system programming.




About Me

Category : From the Author     Tags :  

I'm a fans of browser based games and I have been hooked onto it several years ago. Over the years, I have been playing numerous web games and was really fascinated with it and I really wish that I could build my own PBBG one day. Back then, I know nothing about building a web game, I don't even know how to make a simple web page not to mention programming a complex web game system.

How I jump into this PBBG developer bandwagon?
The first time I attempt to create a simple web page using HTML. I felt it was so troublesome needed to type a whole lots of code just to make a simple web page. I gave up within the same day.
After several months, I tried again. Putting up pieces of HTML code together, it took me several days just to make the web page which looks fairly 'okay'. With some compliments from other game members, I continue to learn more and more HTML coding.

PHP... More than meet the eyes
One of the game members introduced me to PHP. I have never heard what was PHP back then. He provide some simple guidance and example what PHP can do to make a dynamic website instead of my static HTML website. I was really impressed of how much PHP could do and that is when I started to get addicted with PHP programming.

Building my first PHP Game.
I build my first PHP Game somewhere in 2005. I guess I have made the game a little too big and I don't even have a full plan on what the game should accomplish. Somehow, the game manage to score 1 million pagehits in just short period of time during the beta test stage. Unfortunately, I have running out of idea to further develop the game and eventually the game just dissapear.

Further down the road, I tried to code a few more web games but I have not enough time to manage the games and it just went off from the planet. Although I have lost all the games I have built but I still continues to code web games and now, I wish to share my experience in web game development with everyone.




< Previous Page


Custom Search


Make Web Game Tutorial
Part 1: How to make a web game
Part 2: Learn HTML to make your webite
Part 3: How to use CSS to format your website

Ads