Jump to content

Login.php


yrstruly
 Share

Recommended Posts

I have the following two ccodes that displays the php info page(i only included a snipped of the whole file). What am i doing wrong, its not suppose to display this is it?PHP Version 5.2.8System Windows NT ANTHONY 5.1 build 2600Build Date Dec 8 2008 19:30:48Configure Command cscript /nologo configure.js "--enable-snapshot-build" "--enable-debug-pack" "--with-snapshot-template=d:\php-sdk\snap_5_2\vc6\x86\template" "--with-php-build=d:\php-sdk\snap_5_2\vc6\x86\php_build" "--with-pdo-oci=D:\php-sdk\oracle\instantclient10\sdk,shared" "--with-oci8=D:\php-sdk\oracle\instantclient10\sdk,shared"Server API Apache 2.0 HandlerVirtual Directory Support enabledConfiguration File (php.ini) Path C:\WINDOWSLoaded Configuration File C:\xampp\apache\bin\php.iniScan this dir for additional .ini files (none)additional .ini files parsed (none)PHP API 20041225PHP Extension 20060613Zend Extension 220060519Debug Build noThread Safety enabledZend Memory Manager enabledIPv6 Support enabledRegistered PHP Streams php, file, data, http, ftp, compress.zlib, zipRegistered Stream Socket Transports tcp, udpRegistered Stream Filters convert.iconv.*, string.rot13, string.toupper, string.tolower, string.strip_tags, convert.*, consumed, zlib.*Zend logo This program makes use of the Zend Scripting Language Engine:Zend Engine v2.2.0, Copyright © 1998-2008 Zend Technologies with Zend Extension Manager v1.2.0, Copyright © 2003-2007, by Zend Technologies with Zend Optimizer v3.3.3, Copyright © 1998-2007, by Zend Technologies<?php # Script 4.3 - login.php /* This page uses PEAR Auth to control access. * This assumes a database called "auth", * accessible to a MySQL user of "username@localhost" * with a password of "password". * Table definition: CREATE TABLE auth ( username VARCHAR(50) default '' NOT NULL, password VARCHAR(32) default '' NOT NULL, PRIMARY KEY (username), KEY (password) ) * MD5() is used to encrypt the passwords. */ // Need the PEAR class: require_once ('Auth.php'); // Function for showing a login form: function show_login_form() { echo '<form method="post" action="login.php"> <p>Username <input type="text" name="username" /></p> <p>Password <input type="password" name="password" /></p> <input type="submit" value="Login" /> </form><br /> '; } // End of show_login_form() function. // Connect to the database: $options = array('dsn' => 'mysql://username:password@localhost/auth'); // Create the Auth object: $auth = new Auth('DB', $options, 'show_login_form'); // Add a new user: $auth->addUser('me', 'mypass'); ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" /> <title>Restricted Page</title> </head> <body> <?php // Start the authorization: $auth->start(); // Confirm authorization: if ($auth->checkAuth()) { echo '<p>You are logged in and can read this. How cool is that?</p>'; } else { // Unauthorized. echo '<p>You must be logged in to access this page.</p>'; } ?> </body> </html><?php # Script 4.4 - custom_auth.php /* This page uses PEAR Auth to control access. * This assumes a database called "auth", * accessible to a MySQL user of "username@localhost" * with a password of "password". * Table definition: CREATE TABLE users ( user_id INT UNSIGNED NOT NULL AUTO_INCREMENT, email VARCHAR(60) NOT NULL, pass CHAR(40) NOT NULL, first_name VARCHAR (20) NOT NULL, last_name VARCHAR(40) NOT NULL, PRIMARY KEY (user_id), UNIQUE (email), KEY (email, pass) ) * SHA1() is used to encrypt the passwords. */ // Need the PEAR class: require_once ('Auth.php'); // Function for showing a login form: function show_login_form() { echo '<form method="post" action="custom_auth.php"> <p>Email <input type="text" name="username" /></p> <p>Password <input type="password" name="password" /></p> <input type="submit" value="Login" /> </form><br /> ';} // End of show_login_form() function. // All options: // Use specific username and password columns. // Use SHA1() to encrypt the passwords. // Retrieve all fields. $options = array( 'dsn' => 'mysql://username:password@localhost/auth', 'table' => 'users', 'usernamecol' => 'email', 'passwordcol' => 'pass', 'cryptType' => 'sha1', 'db_fields' => '*' ); // Create the Auth object: $auth = new Auth('DB', $options, 'show_login_form'); // Add a new user: $auth->addUser('me@example.com', 'mypass', array('first_name' => 'Larry', 'last_name' =>'Ullman')); ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" /> <title>Restricted Page</title> </head> <body> <?php // Start the authorization: $auth->start(); // Confirm authorization: if ($auth->checkAuth()) { // Print the user's name: echo "<p>You, {$auth->getAuthData('first_name')} {$auth->getAuthData('last_name')}, arelogged in and can read this. How cool is that?</p>"; } else { // Unauthorized. echo '<p>You must be logged in to access this page.</p>'; } ?> </body> </html>

Link to comment
Share on other sites

I don't see a call to phpinfo there, check the included files and see if any of them are running phpinfo.
Hi thank you for the reply. Can you just explain to what you are saying? I should check the includes file,which is where and how?
Link to comment
Share on other sites

If you're seeing the phpinfo page, then that means that somewhere your script is running phpinfo(); I don't see that in the code you posted, so check inside the include files to see if any of them are running phpinfo. Include files are included using either an include or require statement, so check for include and require statements to see what other files are being included.

Link to comment
Share on other sites

If you're seeing the phpinfo page, then that means that somewhere your script is running phpinfo(); I don't see that in the code you posted, so check inside the include files to see if any of them are running phpinfo. Include files are included using either an include or require statement, so check for include and require statements to see what other files are being included.
Hi i have this:require_once ('Auth.php'); I havent saved such a file yet, so i dont know where that script is running from. Please help?
Link to comment
Share on other sites

Hi i have this:require_once ('Auth.php'); I havent saved such a file yet, so i dont know where that script is running from. Please help?
If it's not giving an error about that then it can find the file. If the file didn't exist it would give a fatal error saying that it couldn't open the file. PHP uses an include path to look for files, so you can print that out to see where it's looking:echo ini_get('include_path');It will give a list of several locations where it looks for include files. You might already have Pear installed.There are several examples of installing Pear packages online:http://www.google.com/search?client=opera&...-8&oe=utf-8
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...