How to quickly install the PHP login script without any hassle in 15 steps.
Submitted by Luke Williams.
So Martin Tsachev's PHP Login script didn't work right out of the zip for you, eh? Well neither for me, and although it may have been tough, I managed it in the end. This file is intended for people with not as much experience as myself to get it going.
First of all, this file is meant for people running a Linux system with at least a webserver, MySQL and PHP installed and running. PEAR is also recommended as I will not be explaining how to install it here, rather mentioning how to find it. I accept that most users will probably be running windows, however, and parts of this tutorial may still be helpful to them. The windows-applicable steps are marked with a *.
So, here is my tried and tested (across all of two machines!) method to get it going:
/var/www/html/ (windows users to where your web root directory is)/usr/share/pear/ directory.
(Windows users and those who can't quite figure out this step, further instructions can be added here on request)/var/www/html or your document root
mysqladmin CREATE shaggy mysql shaggy < php-login-script.sql mysql shaggy GRANT ALL PRIVILEGES ON *.* TO shaggy@localhost IDENTIFIED BY 'password';
$db = DB::connect($dsn);
if(DB::isError($db)) {
die($db->getMessage());
}
This will alert you if there is an error with the database./sbin/service httpd restart /sbin/service mysqld restartThe commands may need adjustment, check your OS documentation if these don't work for you.
function begin_head($doctype = true) {
echo '<html><head><title>Login here</title></head><body>';
} // begin_head
function begin_body() {
echo 'Welcome to the login page.</body></html><?php ';
} // begin_body
function footer() {
echo '</html>';
}
http://localhost/index.php (if that doesn't work try http://127.0.0.1/index.php)
Comments
Contacting Luke
You can contact Luke Williams by email if needed.
i like this web page
Hey bud i like the webpage but i want this page to provide the user with other good download facilities..and programmer can submit their projects here.
great
Thanks for this great page, but could somebody tell me how to use the PEAR files with Windows ?
html_form.php
There are still a couple of files that need moving around in different directories, but the only file I can not fix is:
html_form.php
I get this:
Welcome to the login page. Warning: main(html_form.php): failed to open stream: No such file or directory in /var/www/html/user/signup.php on line 20
The PEAR HTML Form is found in "HTML/Form.php" but the class is called HTML_Form.
Can someone that got this working zip it all up and submit it?
html_form.php
Ah, here it is:
html_form
Encryption/Decryption
If i encrypt the password with md5 function, can it be decrypted so I can send the password to the user's email on request?? How is that possible for users want to retrieve their password?? Thanks
no .php extension
I notice that in the script all your links do not include the .php extension. On my server this gives an error saying 'page can not be found'.
How did you manage to make your server not require the .php extension?
Thanks.
Questions Answered
Sorry guys, haven't been watching this site as much as I should, anyway, here's my attempt to answer your questions:
eikcam: Don't know whats up with that either. Just put the extension where it's needed and everything is happy.
Vinh Vu: No. MD5 is one-way encryption. There is now way of retrieving the password.
Dr.Acula (and others): You won't find much more ready made than this. Try and learn some background about what you are doing, it'll help you understand how to make things work.
Krock (and others): Look at pear.php.net for all your needs.
Arnaud: Email me and I might be able to assist you there.
Thats all I have time for now, just ask for anything else you need.
--Luke
PEAR.php.net Has no such file
Why isn't anyone answering the number one question that everyone has asked... Where do we find the "DB_Common" PEAR package, the site you listed "pear.php.net" does not have this file, nor is it even in their search database. There are a total of 17 packages for Database and none are for DB_Common. There is DB, DBA, DBA_Relational, DB_ado, DB_DataObject, DB_DataObject_FormBuilder, DB_ldap, DB_ldap2, DB_NestedSet, DB_Pager, DB_QueryTool and DB_Table. That's all for the DB named files, so maybe you have another site or place we can obtain it from cause it's not there.
Undefined index: REQUEST_URI
Hi there...
While I was attempting to browse the sample-code via the index.php page I got this error message: " Notice: Undefined index: REQUEST_URI in C:\Inetpub\wwwtest\lib\user.php on line 234 "
What is the meanning of this error?
And how can I correct it?
Thanks a lot in advantage. :)
Login script works fine
Hi
After a little hard handwork, PHP login script works fine on my linux box.
Thanks Martin.
I suggest you to rewrite this step by step guide to adapt on to reality framework.
Joaquin
Joaquin
no such DB
See my comments above, but I was also able to connect to the database remotely via Access, and was able to add a row to the members table. Also the scripts and the database are running on the same Redhat 8.0 server. I am also able to connect to the database using mysql -u shaggy -p. I have a fealing it has something to do with the pear modules, but I am not 100% sure since I am new at this.
I did update to the latest version of DB pear files, and I have confirmed that mysqld is running and listening on TCP port 3306, and there is an entry in the /etc/services for 3306 pointing to mysql. Any help would be greatly appreciated.
Thanks
paul
point 9.
Hi,
I do think I have got this right.
but where do i find DB_Common, HTML_Common, HTML_Table, HTML_Form ?
I use Fedora core 2 and have used yum to install most of php-pear. But when i do a locate DB_Common, HTML_Common, HTML_Table, HTML_Form i dont find any of them. Just DB.
what do i do to get this? and what is the right place to place dem?
regards
martin
Figured it all out
So, there are alot of things you're not told here.
I went throught he entire process of installing PEAR on my home computer; I've got PHP, MySQL and Apache installed already.
There are several things you are not told.
Here are some more specific instructions for installing this little piece of software.
Your directory structure MUST look like this (I named my main folder 'loginscript' because I have another index file in my main public_html directory):
www/config.php
www/loginscript/common.js
www/loginscript/filter.php
www/loginscript/html_form.php
www/loginscript/functions.php
www/loginscript/global.php
www/loginscript/index.php
www/loginscript/list.php
www/loginscript/multipage.php
www/loginscript/session_defaults.php
www/loginscript/details.php
www/loginscript/lib/user.php
www/loginscript/user/edit.php
www/loginscript/user/login.php
www/loginscript/user/logout.php
www/loginscript/user/password.php
www/loginscript/user/signup.php
In each of the www/loginscript/user/ files, you MUST add the line
require_once '../global.php';
At the VERY TOP of the file just inside the PHP tags (after the comment though).
Additionally, in each of the files in
www/loginscript/user/
CHANGE THE FOLLOWING!
require_once 'html_table.php';
TO
require_once '../html_table.php';
That should do it. Works perfectly on my home server now.
Funny part is, all this was just an exercise, I already have a very nice login script I wrote myself, just thought I'd play around with one that is OOP..
On the upside I did learn to use PEAR and install it myself, and I got some exposure to the HTML tables classes.
Not a nube - but not able to get it to work
Well, I'm stumped. I've installed all of the files, as described, configured everything per instructions, I've got a bit of experience with PHP/MySQL/PEAR, but when I attempt to login... nothing. Nothing happens at all. Clicking on the submit button gets NO action whatsoever. Any suggestions?
blank page
I download the script. I got most errors many of you have. To resolve most issues you must download few PEAR PHP packages and decompress them in the directory where PHP could find them.
If you have IS_A not found error, you must include two lines in DB.php at the beggining: require_once 'compat.php'; PHP_Compat::LoadFunction('is_a');
this is cause your version of php does not have that function. PHP_Compat is a PEAR PHP package. also is DB.
Other errors like SetFetch... not found, are cause some PEAR packages call php files in subdirectories that does not exist. For example: you must open mysql.php in DB directory where you decompress the PEAR package and change a call to '/DB/common.php' and changing to 'common.php' cause that file is in the same directory of mysql.php.
So what I recommend you, is to download all necessary PEAR packages, install them in the right directory and check for bad file references in php files. That should solve most problems.
What I could not resolve, is to assign privileges to shaggy in .
I am running mysql in cygwin in a win XP computer. I dont have admin privileges, but up to know I was able to run every service.
I tried with differents user and passwords but I get the same error "ERROR 1045: Access denied for user: '@localhost' (Using password: NO)"
I load http://localhost/~myuser
and I just get a blank page.
with no error. I check source code of the generated page, and is blank.
Any help?
is_a()
I don't know if I'm beig silly but is_a();
isn't just a mistake for is_array();
it worked!
Not for beginners
This tutorial is not for beginners, it is an advanced script for advanced users who don't know how to or don't have time to write their own secure script.
Sorry, that sounded harsh
I may write a beginners script though, if I get enough requests for it,
yes please luke.. i would be very very happy if you could give me a simpler tutorial. i am currently trying to put the script on my web server but the tutorial seems too hard for me. i wish the zip contains files ready to be extracted and used (of course with the exception of creating sql database and similars).
Thanks for a great piece of software. I'd real problems trying to build something so comprehensive myself. I'll admit it's a little tricky to get going first especially given the different problems people have and solutions they suggest. A step by step guide would be a very cool idea but also if Luke was to create a simple script users could follow.
Thanks for your contribution to the PHP community
Thanks for Guide, but i can't restart apache with /sbin/service httpd restart . Where is my mistake ?
I keep getting
DB Error: not found
I've checked the database name, username and password, all are correct.
Does anyone know what could be wrong here?