By Tim Perdue on July 30, 2000 When I started seeing spam messages posted to the new column annotation system, I knew I would have to create some sort of user authentication system that helps weed out the losers. I’m the type that would rather write an entire library myself…
PHP Tutorials
Whether just getting started or an expert, this vast collection of PHP tutorials will help you create dynamic content for powerful web-based applications in no time.
By Tim Perdue on July 30, 2000 Here are the two critical functions in this library – the token creation and token verification functions. Don’t worry – the rest of the library is included here as well. <?php $hidden_hash_var=’your_secret_password_here’; $LOGGED_IN=false; unset($LOGGED_IN); function user_isloggedin() { global $user_name,$id_hash,$hidden_hash_var,$LOGGED_IN; //have we already run the hash checks? //If so, return the pre-set, trusted var if ( isset($LOGGED_IN) ) { return $LOGGED_IN; } //are both cookies present?…
By Tim Perdue on July 30, 2000 When I first wrote this column back in January 1999, I had no clue that it was going to be so wildly popular, and I had even less of a clue that PHPBuilder was going to take off and become as widely-used as…
By Tim Perdue on July 30, 2000 Removing the ‘?’ and ‘&’ from the URL string is a necessary first step, and it’s sufficient for many tasks. However, you can take it further by having context-sensitve meta tags generated on the fly for every page. When I build a site,…
By Tim Perdue on July 30, 2000 Let’s go into more detail now: <?php //sample shared.inc file //set up database connections //any global variables for background // colors or path names function site_header($title) { //contains common HTML //for the header echo ‘<HTML> <HEAD> <TITLE>PHPBuilder.com – ‘.$title.'</TITLE>’; //set up metatags //take out “the”, “and” and “a” //a truly gifted developer would use //a great Regular Expression here $keywords=str_replace(“the “,”,strtolower($title)); $keywords=str_replace(“a “,”,$keywords); $keywords=str_replace(“and “,”,$keywords); $keywords=str_replace(“””,”,$keywords); //make the string comma-separated $meta_array=explode(‘ ‘,$keywords); $meta_words=implode($meta_array,’, ‘); echo ‘ <META NAME=”KEYWORDS” CONTENT=”PHP, ‘.$meta_words.'”> <META NAME=”DESCRIPTION” CONTENT=”PHP Developer, Web Developer, ‘.$title.'”> ‘; echo ‘</HEAD> <BODY TEXT=”#000099″ BGCOLOR=”#FFFFFF”>’; } function site_footer() { //contains common html //for the footer echo ‘</BODY></HTML>’; } ?> There, now…
By Tim Perdue on July 30, 2000 The following code is what I used in the construction of Gotocity.com. My goal was, as I mentioned, to eliminate all ‘?’ and ‘&’ characters from the URL. I wanted to drill down from the general (country, in this case the US) to…
By Tim Perdue on July 30, 2000 Which database do I use: Postgres or MySQL? This age-old question has plagued developers for, what, at least a couple years now. I’ve used both databases extensively (MySQL for about one year and Postgres for about 2 years) and was curious if the…
By Tim Perdue on July 30, 2000 Methodology To try to make this as realistic as possible, I took an actual page from a website and made it portable across both MySQL and Postgres. This basically meant replacing all mysql_query() calls with pg_exec(). This page involves a lot of selects…
By Tim Perdue on July 30, 2000 MySQL The numbers for MySQL ring true with what most people already know: it’s a fast, although lightweight database that will probably serve well for the vast majority of web sites. However, if you plan on having a high-traffic site (say, greater than…
By Tim Perdue on July 30, 2000 Conclusion These tests pretty much confirmed what I already knew – both databases serve quite well for the vast majority of web sites out there. Both are actually extremely fast when compared to desktop databases like FileMaker and MS Access. Both are now…