WeberDev.com PHP and MySQL Code

LOG IN
BEGINNER GUIDES  |  PHP CLASSES  |  CODE SEARCH  |  ARTICLES SEARCH  |  PHP FORUMS  |  PHP MANUAL  |  PHP FUNCTIONS LIST  |  WEB SITE TEMPLATES
Start typing to search for PHP and MySQL Code Snippets and Articles Search
Submit a code Example / Snippet Submit Your Code
Search Engine Optimization Monitor SEO Monitor
Web Site UpTime Monitor UpTime Monitor
WeberDev's Monthly code contest PHP Code Contest
Your Personal Examples List My Favorite Examples
Your Personal Articles List My Favorite Articles
Edit Account Info Update Your Profile
PHP Code Search
Web Development Forums
Learn MySQL Playing Trivia
PHPBB2 Templates
Web Development Index
PHP Web Logs (BLogs)
Web Development Resources
Web Development Content
PHPClasses
PHP Editor
PHP Jobs
Vision.To Design
Ajax Tutorials
PHP Programming Help
PHP/MySQL Programming
Webmaster Resources
Webmaster Forum
XML meta language
website builder
Submit Site
Forex Trading Online forex trading platform

Go Back Add a Comment Send this example to a friend Add this Article to your personal favoritest for easy future access to your favorite Code Examples and Articles. Submit a code example Print this code example.
BACK ADD A COMMENT SEND TO A FRIEND ADD TO MY FAVORITES ADD CODE EXAMPLES PRINT
Title : Using Postgres and PHP3 Authentication from a Web application
Categories : PostgreSQL, HTML and PHP, Authentication, PHP Update Picture
Eric Oliveri
Date : Jul 17th 1998
Grade : 1 of 5 (graded 3 times)
Viewed : 9634
File : No file for this code example.
Images : No Images for this code example.
Search : More code by Eric Oliveri
Action : Grade This Code Example
Tools : My Examples List

  Submit your own code examples 
 

//--------------------------------------------------------------
// This little PHP script shows you how to connect to a Postgres
// database via a browser with User/Password database
// authentication using PHP3 authenticate function.
//--------------------------------------------------------------
// 1) You have to modify the $PGDATA/pg_hba.conf file:
// local all trust
// -> trusting all connection for everyone on local machine
// host all 127.0.0.1 255.255.255.255 password passwd
// -> using password like file (passwd made using pg_passwd tool
// to create user password account) to authenticate users
// from everywhere
// 2) Just use the pg_Connect (or pg_pConnect) function with the
// connection string as follows.
//--------------------------------------------------------------



<?PHP

//--------------------------------------------------------------
// Authentication function - see previous archives for comments
//--------------------------------------------------------------

function authenticate() {
Header("WWW-authenticate: basic realm=\"Intranet MBDS\"");
Header("HTTP/1.0 401 Unauthorized");
$title="Login invalide";
?>
In order to proceed you will need a valid username/password.
<?
exit;
}

//--------------------------------------------------------------
// Postgres Connection
//--------------------------------------------------------------

function connect($user,$passwd) {

// You simply have to change the following variables to match
// your site configuration
// HOSTNAME = name of your postgres base host
// DBNAME = name of your postgres base

$conn = pg_Connect("host=HOSTNAME dbname=DBNAME port=5432
user=$user password=$passwd");

// Db connection problem
if (!$conn) {
echo "Database connection error.\n";
exit;
}

// SQL order
$query_parent="SELECT * FROM xxxx WHERE xxxx";
$result = pg_Exec($conn,$query_parent);

if (!$result) {
echo "SQL order problem.\n";
exit;
}

// ...

// End of SQL statment
pg_FreeResult($result);
pg_Close($conn);
}

//--------------------------------------------------------------
// Main part of your PHP script
//--------------------------------------------------------------


if (!isset($PHP_AUTH_USER)) {
authenticate();
}
else {
connect($PHP_AUTH_USER,$PHP_AUTH_PW);
}

?>



Complete, simple working example of login screen and check on a unique page using php functions, cookies and mysql database.
Categories : PHP, Cookies, MySQL, HTML and PHP, Authentication
AUTH (.htaccess style) - a login system that uses PostgreSQL.
Categories : PHP, Authentication, Databases, PostgreSQL
Form Security - Match A Value For Success
Categories : PHP, Authentication, HTML and PHP, Sessions, Security
PHP3: Formmail. Just a cgi formmail, but than in PHP. It is easy to use!
Categories : HTML and PHP, Email, PHP, Perl, HTML and PHP
Simple script to passing persistent and growing array between recalls of one page (manipulate little stack).
Categories : Arrays, Global Variables, PHP, HTML and PHP, Variables
Basic Authentication with sessions
Categories : PHP, Beginner Guides, Authentication, Form Processing, Sessions
This is Yet Another Sql Abstraction Library. Include it in your script and you can use the most important SQL functions without worrying about the SQL backend.
Categories : Databases, PHP, ODBC, MySQL, PostgreSQL
Using $PHP_AUTH_USER and $PHP_AUTH_PW to authenticate.
Categories : Authentication, PHP
A simple class with some HTML output functions that would come in handy for consistent page layout etc.
Categories : PHP, PHP Classes, HTML and PHP, HTML, Navigation
Select with current month
Categories : PHP, HTML and PHP, Date Time, Arrays
Calendar using Date function
Categories : HTML and PHP, PHP, Date Time, Calendar
phpCards - PHP/mySQL postcard script with web based admin to add, edit, and delete cards and categories. Very easy to install.
Categories : PHP, Complete Programs, HTML and PHP, MySQL
PHP, simple, counter, bala
Categories : HTML and PHP, PHP, PHP Options and Info
Automatically printing the contents of an sql table in MySQL.
Categories : MySQL, PHP, HTML and PHP, Databases
PHP4 session helper HTML file.
Categories : PHP, Java Script, HTML and PHP, Sessions