|
Samay Live | |
|
EBooks » Web Tutorials
by enygma There are many
ways to go about authenticating a user for your site, some are more
secure than others. The one that will be discussed here is doing the
authentication from a MySQL database.
To begin with, we will help you create the database that we
will use to authenticate off of. Keep in mind, this is a very simple
tutorial and there are many other ways for you to do this. Obviously,
you'll need MySQL up and running on your machine and know a bit about
how to use it. If you don't know how to use MySQL yet, poke around on
the net and look for an introduction. I'm sure there is one somewhere.
On numerous occassions I have been asked how to serve images from a
non-web accessible directory. A lot of sites now a days sell content
and with the latest in php technologies like sessions and such, people
like to use session management and authentication on their websites,
without using .htaccess files in their directory. The easiest solution
to protecting images is by reading them from a directory outside the
document root on the webserver and serving it to another php script.
This helps in two ways. 1. People cannot link directly to your images via a URL. 2. You can
use another script to serve the image and make people login to view the
image as well you could use your own html design dynamically around the
image.
The goal of this tutorial, as you probably guessed by the title, is to
help you (yes you) create your very own news-driven web site. Now, this
doesn't have to be a system as glorified as something like Slashdot or
some of the other big news sites. All you may need is a simple system
for displaying news and for editing/adding news to the front page.
Well, look no further - I will show you how to create a nice simple
news-driven site using nothing but some pretty simple PHP and a MySQL
database. Now, this can be done without a database by using a text file
or something, but that's a bit more difficult. You'd have to write
something to parse out the info you needed and something to put it in
the right place when you were adding to it. For the sake of ease, we're
going to use a simple MySQL database. In the following tutorial I'll show you a peek at the power of coupling
GD with PHP to create a basic button. The GD extension is more or less
an addon for PHP to allow for image manipulation and creation and has
to be compiled in when you compile PHP and the rest of the software.
The GD extensions currently support PNG and JPEG image formats, as GIF
support was removed in version 1.6 because of legalities dealing with
the GIF format. (A patch is available to restore this functionality.)
The following tutorial will be using PNG format images (the images on
this tutorial are saved in the GIF format, and are not dynamically
created. Just for compatibility's sake). In using the GD extensions,
they must be compiled with PHP if using on a unix platform, or the
extension php*_gd.dll must be loaded on win32 platforms. The code can
get a bit complicated and I'll assume you know some basics of PHP. What is a cookie?
Sometimes it becomes necessary to track certain user details like (No. Of Visits, names, last visit, etc). The client machine stores such information and sends it to the web server whenever there is a request. Cookies data are sent along with the HTTP headers. You can look at this URL to know more about how they work. http:www.cookiecentral.comfaq
Difference between session and cookie?
The key difference would be cookies are stored in your hard disk whereas a session aren't stored in your hard disk. Sessions are basically like tokens, which are generated at authentication. A session is available as long as the browser is opened.
Sessions are popularly used, as the there is a chance of your cookies getting blocked if the user browser security setting is set high.
Note: When you issue a session_start() it generates a session ID and places that on the client side in a cookie. There are also some ways to avoid this using the tag rewrite.
|
| |
|