<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
    xmlns:content="http://purl.org/rss/1.0/modules/content/"
    xmlns:wfw="http://wellformedweb.org/CommentAPI/"
    xmlns:dc="http://purl.org/dc/elements/1.1/"
    xmlns:atom="http://www.w3.org/2005/Atom"
    xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
    xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
    >

<channel>
    <title>Webmonkey &#187; PHP</title>
    <atom:link href="http://www.webmonkey.com/tag/php/feed/" rel="self" type="application/rss+xml" />
    <link>http://www.webmonkey.com</link>
    <description>The Web Developer&#039;s Resource</description>
    <lastBuildDate>Mon, 06 May 2013 17:29:19 +0000</lastBuildDate>
    <language>en-US</language>
    <sy:updatePeriod>hourly</sy:updatePeriod>
    <sy:updateFrequency>1</sy:updateFrequency>
    <generator>http://wordpress.org/?v=3.4.2</generator>
    
    <item>
        <title>Generate PDFs Dynamically With PHP</title>
        <link>http://www.webmonkey.com/2010/02/generate_pdfs_dynamically_with_php/</link>
        <comments>http://www.webmonkey.com/2010/02/generate_pdfs_dynamically_with_php/#comments</comments>
        <pubDate>Tue, 16 Feb 2010 01:45:47 +0000</pubDate>

                <dc:creator>Webmonkey Staff</dc:creator>

        <guid isPermaLink="false">http://stag.wired.com/primate/?p=731</guid>
        		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[pdf]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[wiki]]></category>
        <description><![CDATA[PDF is the Portable Document Format developed by Adobe. It&#8217;s an open standard implemented by Adobe in their Acrobat series of software, but implementable and extensible by anybody who&#8217;s got the time, inclination, and knack. One trick that&#8217;s got a lot of potential is using PHP to dynamically generate PDF files and serve them via [...]]]></description>

            <content:encoded><![CDATA[<!-- wpautop disabled --><p>PDF is the Portable Document Format developed by Adobe. It&#8217;s an <a href="http://www.adobe.com/devnet/acrobat/" class="external text" title="http://www.adobe.com/devnet/acrobat/" rel="nofollow">open standard</a> implemented by Adobe in their Acrobat series of software, but implementable and extensible by anybody who&#8217;s got the time, inclination, and knack. One trick that&#8217;s got a lot of potential is using PHP to dynamically generate PDF files and serve them via the web.

</p><p>PHP can do a lot for your web operation (read our <a href="/2010/02/PHP_Tutorial_for_Beginners" title="Tutorial:PHP Tutorial for Beginners">PHP Tutorial for Beginners</a> tutorial). You can generate nice-looking printable receipts, invoices, and brochures. <a href="http://www.vanhemert.co.uk/disc-cover.html" class="external text" title="http://www.vanhemert.co.uk/disc-cover.html" rel="nofollow">Disc-Cover</a> has a test site that looks up info about a CD automatically and then generates a PDF label for the CD box that you can print, cut out, and use. And there are literally one billion other possible uses for dynamically generated PDFs.

</p><p>So what are you waiting for?

</p><p>You have a variety of PDF-generation options. The standard, classic way of doing it is with <a href="http://www.pdflib.com/" class="external text" title="http://www.pdflib.com/" rel="nofollow">PDFlib</a>. Because it&#8217;s so widely used and well-integrated into PHP, that&#8217;s the library I&#8217;ll go over today. But it&#8217;s by no means the only way of doing things. PDFlib is source-available, but not free. The license specifies that PDFlib can be used and redistributed without charge for non-commercial projects, but commercial use carries a fee.



</p><p>There are also a number of completely free options. These include <a href="http://www.ros.co.nz/pdf/" class="external text" title="http://www.ros.co.nz/pdf/" rel="nofollow">R&amp;OS</a> and <a href="http://www.fpdf.org/en/home.php" class="external text" title="http://www.fpdf.org/en/home.php" rel="nofollow">FPDF</a>, <a href="http://www.stillhq.com/opensource.html" class="external text" title="http://www.stillhq.com/opensource.html" rel="nofollow">Panda</a>. The choice is yours. (I haven&#8217;t had a chance to test these free packages very thoroughly. If you have had negative or positive experiences with them, please do <a href="mailto:adams@pote.com" class="external text" title="mailto:adams@pote.com" rel="nofollow">let me know</a>.)

</p><span id="more-731"></span><p><br />

</p>

<table id="toc" class="toc" summary="Contents"><tbody><tr><td><div id="toctitle"><h2>Contents</h2> </div>



<ol>

<li><a href="#Installing_It">Installing It</a></li>

<li><a href="#Using_It">Using It</a></li>

<li><a href="#Displaying_Text">Displaying Text</a></li>

<li><a href="#Wrapping_Up">Wrapping Up</a></li>



</ol>

</td></tr></tbody></table>



<a name="Installing_It"></a><h3> <span class="mw-headline">Installing It</span></h3>

<p>In order to install PDFlib, you first have to download the <a href="http://www.pdflib.com/download/" class="external text" title="http://www.pdflib.com/download/" rel="nofollow">PDFlib</a> source (precompiled binaries are available but they watermark their output). Uncompress the package and compile and install it according to the instructions for your platform. We are assuming that you already have a working build of PHP. Instructions for installing PDFlib are included with the download, but I&#8217;ll go over the instructions for Unixy systems (including Mac OS X) anyway.

</p><p>This article may become dated in terms of version and patch information. In general, it&#8217;s a good idea to download the <a href="http://www.pdflib.com/fileadmin/pdflib/pdf/support/PDFlib-in-PHP-HowTo.pdf" class="external text" title="http://www.pdflib.com/fileadmin/pdflib/pdf/support/PDFlib-in-PHP-HowTo.pdf" rel="nofollow">PDFlib on PHP manual</a> (PDF link) and read the most current instructions before installing PDFlib.

</p><p>Install all the files in their appropriate places according to the instructions.

</p><p>In your PHP directory, rebuild the configure file:<tt>./buildconf</tt>



</p><p>Rebuild PHP, adding the switch <tt>--with-pdflib=PDFDIR</tt> (change PDFDIR to the name of the directory where PDFlib is installed).

</p><p>Restart Apache, and there you go.

</p><p><br />

</p>

<a name="Using_It"></a><h3> <span class="mw-headline">Using It</span></h3>

<p>PDFlib, in conjunction with PHP, has over a hundred functions available for creating PDFs. To conserve time, space, and sanity, I&#8217;ll only cover a few of these. The full gamut is explained both on the <a href="http://www.php.net/manual/en/ref.pdf.php" class="external text" title="http://www.php.net/manual/en/ref.pdf.php" rel="nofollow">PHP site</a> and in the documentation that accompanies the PDFlib download.

</p><p>Let&#8217;s zip through a step-by-step explanation of creating a new PDF document. Nothing fancy, just a couple of lines of text on a page. To start with, we need to initialize a new PDF object with the pdf_new() function. We will assign the object to the variable $pdf. This object handle is how we&#8217;ll refer to the PDF we&#8217;re creating from now on.

</p>

<pre class="brush: js">  $pdf = pdf_new();



</pre>

<p>Next we want to create a new blank PDF file. This is done with the <a href="http://www.php.net/manual/en/function.pdf-begin-document.php" class="external text" title="http://www.php.net/manual/en/function.pdf-begin-document.php" rel="nofollow">PDF_begin_document()</a> function. We tell it the name of the PDF object we&#8217;re working with:

</p>

<pre class="brush: js">  PDF_begin_document($pdf);

</pre>

<p>Moving swiftly along:we&#8217;ve got a PDF object containing one blank PDF file. Now we start to fill it in. First let&#8217;s set the metadata fields for the PDF. This step is optional. Every PDF has header information in which the document title, creator, and so forth can be specified. We set this data with the <a href="http://www.php.net/manual/en/function.pdf-set-info.php" class="external text" title="http://www.php.net/manual/en/function.pdf-set-info.php" rel="nofollow">pdf_set_info()</a> function. This function takes three arguments:the PDF object we&#8217;re working with, the name of the property we want to set, and the value we want to set it to. The predefined property names you can use are Author, Creator, Keywords, Subject, and Title. So, for example:

</p>

<pre class="brush: js">  pdf_set_info($pdf, "Author", "Paul Adams");

</pre>



<p>Next we create the first page of our PDF, specifying width and then height, in points. A point is 1/72 of an inch, so if we want an 8.5-by-11-inch page, we do a little multiplying:

</p>

<pre class="brush: js">  pdf_begin_page($pdf, (72 * 8.5), (72 * 11));

</pre>

<p>(If you are following along with pencil and paper, you will see that we could have substituted &#8220;612&#8243; and &#8220;792&#8243; for the width and height terms.)

</p><p>Now we&#8217;ve got everything set up. Next, let&#8217;s get to the meat of our PDF:the content. First we need to choose a font to display our text. This is a two-step process:locating the font, and then using it. The PDFlib manual is very helpful on this topic.

</p><p><br />

</p>

<a name="Displaying_Text"></a><h3> <span class="mw-headline">Displaying Text</span></h3>

<p><i>This section covers the use of a <b>depricated function</b>. Please help us keep Webmonkey up to date by editing it.</i>

</p><p>The function we use to locate and prepare the font is <tt>pdf_findfont()</tt>. It takes four arguments:the PDF object handle, the font name, the encoding of the font, and whether or not the font should be embedded in the document. We are going to use one of the 14 fonts built in to PDFlib, which means we don&#8217;t have to get our hands too dirty. It means we don&#8217;t have to embed the font (which we indicate by a &#8220;0&#8243; value for the last argument), and the encoding is &#8220;host&#8221;. These 14 fonts are (still have that pencil ready?):Courier, Courier-Bold, Courier-Oblique, Courier-BoldOblique, Helvetica, Helvetica-Bold, Helvetica-Oblique, Helvetica-BoldOblique, Times-Roman, Times-Bold, Times-Italic, Times-BoldItalic, Symbol, and ZapfDingbats. For our text we&#8217;ll use Times-Roman, okay? pdf_findfont() returns a font handle, which we&#8217;ll pass to the $font variable:



</p>

<pre class="brush: js">  $font = pdf_findfont($pdf, "Times-Roman", "host", 0)

</pre>

<p>If something goes wrong, the font handle $font will be set to &#8220;FALSE&#8221;. But nothing ever goes wrong. Part Two is to tell the renderer that we want to use that font, and to specify the size in points, with:

</p>

  <pre class="brush: js">pdf_setfont().



  pdf_setfont($pdf, $font, 16);

</pre>

<p>Now we&#8217;re almost ready to print our text. We just need to set the position for it to appear, with <tt>pdf_set_text_pos()</tt>. With this function, we specify an X and Y coordinate in points, counting from the lower left corner of the page, which is (0,0). Let&#8217;s print our text near the upper left of the page:

</p>

<pre class="brush: js">  pdf_set_text_pos($pdf, 72, 720);

</pre>

<p>pdf_show() is used to print text at the current position. Its usage is very simple:



</p>

<pre class="brush: js">  pdf_show($pdf, "My First PDF Document");

</pre>

<p>There&#8217;s the text! At last! At this point, if we wanted, we could continue to move around the page, printing more text in various fonts, drawing images, adding new pages, and so forth. But I think we&#8217;ve covered about enough for an intro course. Let&#8217;s close things down.

</p>

<a name="Wrapping_Up"></a><h3> <span class="mw-headline">Wrapping Up</span></h3>

<p>We end the page with the <tt>pdf_end_page()</tt> function:

</p>

<pre class="brush: js">  pdf_end_page($pdf);

</pre>



<p>and then close the object:

</p>

<pre class="brush: js">  pdf_end_document($pdf);

</pre>

<p>The complete PDF document that we&#8217;ve created is now neatly put away in the PHP buffer. In order to display or save it, we need to fetch it from there and do something with it. The <tt>pdf_get_buffer()</tt> function gets the contents of the buffer and puts it into a new variable.

</p>

<pre class="brush: js">  $document = pdf_get_buffer($pdf);

</pre>

<p>Now let&#8217;s create a new PDF &#8212; just kidding. Actually we can&#8217;t use any more PDF functions until we get rid of this object we&#8217;ve just pulled from the buffer. That&#8217;s a safeguard built into the system. We must either send the PDF to the user&#8217;s browser, save it as a file on the server, or delete it from memory. Let&#8217;s do the latter two.

</p><p>To display it, we need to first send HTTP header information, to let the browser know what&#8217;s coming. This is done with the <tt>header()</tt> function. We need to send three headers:Content-Type, Content-Length, and Content-Disposition.



</p><p>First let&#8217;s find the length of the PDF, and give it a filename:

</p>

 <pre class="brush: js"> $length = strlen($document);



  $filename = "myfirstpdf.pdf";

</pre>

<p>Then we output the headers:

</p>

<pre class="brush: js">  header("Content-Type:application/pdf");



  header("Content-Length:" . $length);



  header("Content-Disposition:inline; filename=" . $filename);

</pre>

<p>Now we&#8217;re ready to send the actual document to the browser, with a simple echo() function:

</p>

<pre class="brush: js">  echo($document);

</pre>

<p>All set. Finally, as a last step, we purge the memory to get ready for our next adventure:



</p>

  <pre class="brush: js">unset($document);



  pdf_delete($pdf);

</pre>

<p>Here is a look at all that code assembled in one place:

</p>

<pre class="brush: js">

  &lt;?php



  $pdf = pdf_new();



  pdf_begin_document($pdf);



  pdf_set_info($pdf, "Author", "Paul Adams");



  pdf_begin_page($pdf, (72 * 8.5), (72 * 11));



  $font = pdf_findfont($pdf, "Times-Roman", "host", 0)



  pdf_setfont($pdf, $font, 16);



  pdf_set_text_pos($pdf, 72, 720);



  pdf_show($pdf, "My First PDF Document");



  pdf_end_page($pdf);



  pdf_end_document($pdf);



  $document = pdf_get_buffer($pdf);



  $length = strlen($document);



  $filename = "myfirstpdf.pdf";



  header("Content-Type:application/pdf");



  header("Content-Length:" . $length);



  header("Content-Disposition:inline; filename=" . $filename);



  echo($document);



  unset($document);



  pdf_delete($pdf);



 &nbsp;?&gt;



  </pre>

<p>That&#8217;s kind of a lot of code to print one line of text, it&#8217;s true. But that was just an example. The PDF format wasn&#8217;t invented for displaying single lines (although it does them so nicely!). You can use the framework above to output all kinds of complex PDFs, with logos and diagrams and color and links and whatever. There are simple PHP functions for all that stuff. Just start small and work step-by-step. The PDFlib package includes a very cool demo, called pdfclock, of an analog clock rendered as a dynamic PDF. See where that leads you. Follow your heart.

</p><div id='linker_widget' class='contextly-widget'></div>]]></content:encoded>
            <wfw:commentRss>http://www.webmonkey.com/2010/02/generate_pdfs_dynamically_with_php/feed/</wfw:commentRss>
        <slash:comments>2</slash:comments>

        
    </item>
    
    <item>
        <title>PHP and MySQL Tutorial &#8211; Lesson 3</title>
        <link>http://www.webmonkey.com/2010/02/php_and_mysql_tutorial_-_lesson_3/</link>
        <comments>http://www.webmonkey.com/2010/02/php_and_mysql_tutorial_-_lesson_3/#comments</comments>
        <pubDate>Tue, 16 Feb 2010 01:45:47 +0000</pubDate>

                <dc:creator>Webmonkey Staff</dc:creator>

        <guid isPermaLink="false">http://stag.wired.com/primate/?p=737</guid>
        		<category><![CDATA[Databases]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[wiki]]></category>
        <description><![CDATA[Welcome to the third and final lesson for this tutorial. If you&#8217;ve gone through Lesson 1 and Lesson 2, you already know the essentials for installing and writing useful scripts with MySQL and PHP. We&#8217;re going to look at some useful PHP functions that should make your life a lot easier. First, let&#8217;s look at [...]]]></description>

            <content:encoded><![CDATA[<!-- wpautop disabled --><p>Welcome to the third and final lesson for this tutorial. If you&#8217;ve gone through <a href="/2010/02/PHP_and_MySQL_Tutorial_-_Lesson_1" title="Tutorial:PHP and MySQL Tutorial - Lesson 1"> Lesson 1</a> and <a href="/2010/02/PHP_and_MySQL_Tutorial_-_Lesson_2" title="Tutorial:PHP and MySQL Tutorial - Lesson 2"> Lesson 2</a>, you already know the essentials for installing and writing useful scripts with MySQL and PHP. We&#8217;re going to look at some useful PHP functions that should make your life a lot easier. First, let&#8217;s look at include files.

</p><p>We all know the basics of includes, right? Contents of an external file are referenced and imported into the main file. It&#8217;s pretty easy:You call a file and it&#8217;s included. When we do this in PHP there are two functions we need to talk about:<tt>include()</tt> and <tt>require()</tt>. The difference between these two functions is subtle but important, so let&#8217;s take a closer look. The <tt>require()</tt> function works in a XSSI-like way; files are included as part of the original document as soon as that file is parsed, regardless of its location in the script. So if you decide to place a <tt>require()</tt> function inside a conditional loop, the external file will be included even if that part of the conditional loop is false.</p>
<br />
<span id="more-737"></span>

<p><b>A Place for Everything</b>
</p><p>The <tt>include()</tt> function imports the referenced file each time it is encountered. If it&#8217;s not encountered, PHP won&#8217;t bother with it. This means that you can use <tt>include</tt> in loops and conditional statements, and they&#8217;ll work exactly as planned.

</p><p>Finally, if you use <tt>require()</tt> and the file you&#8217;re including does not exist, your script will halt and produce an error. If you use <tt>include()</tt>, your script will generate a warning, but carry on. You can test this yourself by trying the following script. Run the script, then replace <tt>include()</tt> with <tt>require()</tt> and compare the results.



</p>

<pre class="brush: js">&lt;html&gt;



&lt;body&gt;

&lt;?php

include("emptyfile.inc");

echo "Hello World";

?&gt;

&lt;/body&gt;

&lt;/html&gt;
</pre>

<p>I like to use the suffix .inc with my include files so I can separate them from normal PHP scripts. If you do this, make sure that you set your Web server configuration file to parse .inc files as PHP files. Otherwise, hackers might be able to guess the name of your include files and display them through the browser as text files. This could be bad if you&#8217;ve got sensitive information &#8211; such as database passwords &#8211; contained in the includes.

</p><p>So what are you going to do with include files? Simple! Place information common to all pages inside them. Things like HTML headers, footers, database connection code, and user-defined functions are all good candidates. Paste this text into a file called header.inc.

</p>

<pre class="brush: js">&lt;?php

$db = mysql_connect("localhost", "root");

mysql_select_db("mydb",$db);

?&gt;

&lt;html&gt;

&lt;head&gt;

&lt;title&gt;

&lt;?php echo $title&nbsp;?&gt;

&lt;/title&gt;

&lt;/head&gt;

&lt;body&gt;

&lt;center&gt;&lt;h2&gt;&lt;?php echo $title&nbsp;?&gt;&lt;/h2&gt;&lt;/center&gt;
</pre>

<p>Then create another file called footer.txt that contains some appropriate closing text and tags.

</p><p>Now let&#8217;s create a third file containing the actual PHP script. Try the following code, making sure that your MySQL server is running.

</p>

<pre class="brush: js">&lt;?php

$title = "Hello World";

include("header.inc");

$result = mysql_query("SELECT * FROM employees",$db);

echo "&lt;table border=1&gt;n";

echo "&lt;tr&gt;&lt;td&gt;Name&lt;/td&gt;&lt;td&gt;Position&lt;/tr&gt;n";

while ($myrow = mysql_fetch_row($result)) {

  printf("&lt;tr&gt;&lt;td&gt;%s&nbsp;%s&lt;/td&gt;&lt;td&gt;%s&lt;/tr&gt;n", $myrow[1], $myrow[2], $myrow[3]);

}

echo "&lt;/table&gt;n";

include("footer.inc");

?&gt;
</pre>

<p>See what happens? The include files are tossed into the main file and then the whole thing is executed by PHP. Notice how the variable <tt>$title</tt> was defined before header.inc is referenced. Its value is made available to the code in header.inc; hence, the title of the page is changed. You can now use header.inc across all your PHP pages, and all you&#8217;ll have to do is change the value of <tt>$title</tt> from page to page.

</p><p>Using a combination of includes, HTML, conditional statements, and loops, you can create complex variations from page to page with an absolute minimum of code. Includes become especially useful when used with functions, as we&#8217;ll see down the road.On to the exciting world of data validation.


<a name="Simple_Validation"></a><h4> <span class="mw-headline">Simple Validation</span></h4>

<p>Imagine for a moment that we&#8217;ve got our database nicely laid out and we&#8217;re now requesting information from users that will be inserted into the database. Further, let&#8217;s imagine that you have a field in your database waiting for some numeric input, such as a price. Finally, imagine your application falling over in a screaming heap because some smart aleck put text in that field. MySQL doesn&#8217;t want to see text in that portion of your SQL statement &#8211; and it complains bitterly.

</p><p>What to do? Time to validate.

</p><p>Validation simply means that we&#8217;ll examine a piece of data, usually from an HTML form, and check to make sure that it fits a certain model. This can range from ensuring that a element is not blank to validating that an element meets certain criteria (for example, that a numeric value is stipulated or that an email address contains an @ for an email address).

</p><p>Validation can be done on the server side or on the client side. PHP is used for server-side validation, while JavaScript or another client-based scripting language can provide client-side validation. This article is about PHP, so we&#8217;re going to concentrate on the server end of things.

</p><p>Let&#8217;s ignore our database for the moment and concentrate on PHP validation. If you wish, you can add additional fields to our employee database quite simply by using the MySQL <a href="http://www.mysql.com/Manual_chapter/manual_Reference.html#ALTER_TABLE" class="external text" title="http://www.mysql.com/Manual_chapter/manual_Reference.html#ALTER_TABLE" rel="nofollow">ALTER statement</a> &#8211; that is, if you want to commit to the values that we&#8217;ll validate.

</p><p>There are several useful PHP functions we can use to validate our data, and they range from simple to highly complex. A simple function we could use might be <tt>strlen()</tt>, which tells us the length of the variable.

</p><p>A more complex function would be <tt>ereg()</tt>, which uses full regular expression handling for complex queries. I won&#8217;t delve into the complexities of regex here, as entire books have been written on the subject, but I will provide some examples on the next page.



</p><p>Let&#8217;s start with a simple example. We&#8217;ll check to see whether a variable does or does not exist.

</p>

<pre class="brush: js"> &lt;html&gt;

 &lt;body&gt;

 &lt;?php

 if ($submit) {

      if (!$first ||&nbsp;!$last) {

 	$error = "Sorry! You didn't fill in all the fields!";

 	} else {

 		// process form

 		echo "Thank You!";
 	}
 }

 if (!$submit || $error) {

      echo $error;

     &nbsp;?&gt;

      &lt;P&gt;

      &lt;form method="post" action="&lt;?php echo $PHP_SELF&nbsp;?&gt;"&gt;

      FIELD 1:&lt;input type="text" name="first" value="&lt;?php echo $first&nbsp;?&gt;"&gt;

      &lt;br&gt;

      FIELD 2:&lt;input type="text" name="last" value="&lt;?php echo $last&nbsp;?&gt;"&gt;

      &lt;br&gt;

      &lt;input type="Submit" name="submit" value="Enter Information"&gt;

      &lt;/form&gt;

      &lt;?php

 } // end if

 ?&gt;

 &lt;/body&gt;

 &lt;/html&gt;

</pre>

<p>The keys to this script are the nested conditional statements. The first checks to see whether the Submit button has been pressed. If it has, it goes on to check that both the variables <tt>$first</tt> and <tt>$last</tt> exist. The || symbol means &#8220;or&#8221; and the&nbsp;! symbol means &#8220;not.&#8221; We could also rewrite the statement to say, &#8220;If $first does not exist or $last does not exist, then set $error to the following.&#8221;

</p><p>Next, let&#8217;s extend things a little by checking to see whether a string is a certain length. This would be ideal for passwords, since you don&#8217;t want some lazy user entering a password of only one or two letters. You&#8217;d rather it be, say, six or more characters.

</p><p>The function for this is, as you already know, <tt>strlen()</tt>. It simply returns a number equal to the number of characters in the variable being tested. Here, I modified the script above to check the length of <tt>$first</tt> and <tt>$last</tt>.

</p>

<pre class="brush: js"> &lt;html&gt;

 &lt;body&gt;

 &lt;?php

 if ($submit) {

      if (strlen($first) &lt; 6 || strlen($last) &lt; 6) {

 	$error = "Sorry! You didn't fill in all the fields!";

 	} else {

 		// process form

 		echo "Thank You!";

 	}

 }

 if (!$submit || $error) {

      echo $error;

     &nbsp;?&gt;

      &lt;P&gt;

      &lt;form method="post" action="&lt;?php echo $PHP_SELF&nbsp;?&gt;"&gt;

      FIELD 1:&lt;input type="text" name="first" value="&lt;?php echo $first&nbsp;?&gt;"&gt;

      &lt;br&gt;

      FIELD 2:&lt;input type="text" name="last" value="&lt;?php echo $last&nbsp;?&gt;"&gt;

      &lt;br&gt;

      &lt;input type="Submit" name="submit" value="Enter Information"&gt;

      &lt;/form&gt;

      &lt;?php

 } // end if

 ?&gt;

 &lt;/body&gt;

 &lt;/html&gt;

</pre>

<p>Run this script and try entering six or fewer letters to see what happens. It&#8217;s simple yet quite effective.

</p>

<a name="Not-So-Simple_Validation"></a><h4> <span class="mw-headline">Not-So-Simple Validation</span></h4>

<p>Let&#8217;s talk a bit about using regular expressions with the <tt>ereg()</tt> and <tt>eregi()</tt> functions. As I said earlier, these can be either quite complex or very simple, depending on what you need.

</p><p>Using regular expressions, you can examine a string and intelligently search for patterns and variations to see whether they match the criteria you set. The most common of these involves checking whether an email address is valid (although, of course, there&#8217;s no fail-safe way of doing this).

</p><p>Rather than delve into the mysteries of regular expressions, I&#8217;ll provide some examples. You can use the same form we created on the previous page &#8211; just paste in the lines below to see how they work.

</p><p>First, let&#8217;s make sure that text only has been entered into a form element. This regular expression tests true if the user has entered one or more lowercase characters, from a to z. No numbers are allowed:

</p>

<pre class="brush: js"> if (!ereg("[a-Z]", $first) ||&nbsp;!ereg("[a-Z]", $last)) { </pre>

<p>Now, let&#8217;s extend this expression to check whether the string is four to six characters in length. Using <tt><a href="/special?title=Alpha:&amp;action=edit" class="new" title="Alpha:">alpha:</a></tt> is an easy way to check for valid alphabetic characters. The numbers in the braces check for the number of occurrences. And note that the ^ and $ indicate the beginning and end of the string.

</p>

<pre class="brush: js"> if (!ereg("^[[:alpha:]]{4,6}$", $first) ||&nbsp;!ereg("^[[:alpha:]]{4,6}$", $last)) { </pre>

<p>Finally, let&#8217;s build a regular expression that will check an email address&#8217; validity. There&#8217;s been plenty of discussion about the effectiveness of checking for email addresses in this way. Nothing&#8217;s completely foolproof, but what I have below works pretty well.

</p><p>I took this gem from the PHP <a href="http://www.progressive-comp.com/Lists/?l=php3-general#php3-general" class="external text" title="http://www.progressive-comp.com/Lists/?l=php3-general#php3-general" rel="nofollow">mailing list</a>. It&#8217;s a great resource &#8211; use it. And yes, this is as scary as it looks.

</p>

<pre class="brush: js">	if (!ereg('^[-!#$%&amp;'*+./0-9=?A-Z^_`a-z{|}~]+'.

'@'.

'[-!#$%&amp;'*+/0-9=?A-Z^_`a-z{|}~]+.'.

'[-!#$%&amp;'*+./0-9=?A-Z^_`a-z{|}~]+$', $last)) {

</pre>

<p>Don&#8217;t spend too much time looking at this. Just move on to the next bit.

</p>

<a name="Functions"></a><h4> <span class="mw-headline">Functions</span></h4>

<p>Enjoy that last regex expression? Fun, wasn&#8217;t it? Wouldn&#8217;t it be even more fun to enter that chunk on a dozen different pages that need to process email addresses?! Think about the joy of finding a typo in that mess &#8211; and doing it a dozen times no less. But of course, there&#8217;s a better way.

</p><p>Remember when we talked about include files earlier in this lesson? They&#8217;ll allow us to create a piece of code like the email checker and include it multiple times across several pages. This way, when we want to change the code, we need edit only one file, not many.

</p><p>But if we want to get this done, we&#8217;ll have to use functions.

</p><p>We&#8217;ve already used functions plenty of times. Every time we query the database or check the length of a string we&#8217;re using functions. These functions are built into PHP. If you&#8217;re a keen coder, you can extend PHP with your own customized functions. But that&#8217;s a bit advanced for this tutorial. Instead we&#8217;ll create functions that will reside within our PHP script.

</p><p>A function is simply a block of code that we pass one or more values to. The function then processes the information and returns a value. The function can be as simple or complex as we like, but as long as we can pass a value in and get one out, we don&#8217;t really care how complex it is. That&#8217;s the beauty of functions.

</p><p>Functions in PHP behave similarly to functions in C. When we define the functions, we must specify what values the function can expect to receive. It&#8217;s tricky to get a handle on at first, but it prevents weird things from happening down the road. This is done because the variables inside a function are known as private variables. That is, they exist only inside the function. You may, for instance, have a variable in your script called <tt>$myname</tt>. If you created a function and expected to use the same <tt>$myname</tt> variable (with the same value), it wouldn&#8217;t work. Alternatively, you could have the variable <tt>$myname</tt> in your script and also create another variable called <tt>$myname</tt> in your function, and the two would co-exist quite happily with separate values. I do not recommend doing this, however! When you come back and edit it six months later, you&#8217;ll be breaking things left and right. There are exceptions to this rule as with all things, but that&#8217;s outside the scope of this article.



</p><p>So let&#8217;s create a function. We&#8217;ll start simply. We need to give the function a name and tell it what variables to expect. We also need to define the function before we call it.

</p>

<pre class="brush: js"> &lt;html&gt;
 &lt;body&gt;

 &lt;?php

 function  addnum($first, $second) {

 	$newnum = $first + $second;

	return $newnum;

 }

 echo addnum(4,5);

 ?&gt;

 &lt;/body&gt;

 &lt;/html&gt;

</pre>

<p>That&#8217;s it! First, we created our function. Notice how we defined two new variables, called <tt>$first</tt> and <tt>$second</tt>. When we call the function, each variable is assigned a value based on the order in which it appears in the list &#8211; 4 goes to <tt>$first</tt>, 5 to <tt>$second</tt>. Then we simply added the two numbers together and returned the result. &#8220;Return&#8221; here simply means to send the result back. At the end of the script we print the number 9.

</p><p>Let&#8217;s create something that&#8217;s more useful to our database application. How about something that gracefully handles errors? Try this:

</p>

<pre class="brush: js"> &lt;html&gt;
 &lt;body&gt;

 &lt;?php

 function  do_error($error) {

 	echo  "Hmm, looks like there was a problem here...&lt;br&gt;";

 	echo "The reported error was $error.n&lt;br&gt;";

 	echo "Best you get hold of the site admin and let her know.";

 	die;
 }

 if (!$db = @mysql_connect("localhost","user", "password")) {

 	$db_error = "Could not connect to MySQL Server";

 	do_error($db_error);

 }

 ?&gt;

 &lt;/body&gt;
 &lt;/html&gt;
</pre>

<p>Before running this, try shutting down MySQL or using a bogus username or password. You&#8217;ll get a nice, useful error message. Observant readers will notice the @ symbol in front of <tt>mysql_connect()</tt>. This suppresses error messages so that you get the information only from the function. You&#8217;ll also see we were able to pass a variable into the function, which was defined elsewhere.

</p><p>Remember that I said functions use their own private variables? That was a little white lie. In fact, you can make variables outside of a function accessible to the function. You might create a function to query a database and display a set of results over several pages. You don&#8217;t want to have to pass the database connection identifier into the function every time. So in this situation, you can make connection code available as a global variable. For example:

</p>

<pre class="brush: js">

 &lt;html&gt;

 &lt;body&gt;

 &lt;?php

 function  db_query($sql) {

 	global $db;

 	$result = mysql_query($sql,$db);

 	return $result;

 }

 $sql = "SELECT * FROM mytable";

 $result = db_query($sql);

 ?&gt;

 &lt;/body&gt;

 &lt;/html&gt;
 </pre>

<p>This is a basic function, but the point is that you don&#8217;t need to send <tt>$db</tt> through when you call the function &#8211; you can make it available using the word global. You can define other variables as global in this statement, just separate the variable names by a comma.

</p><p>Finally, you can look like a real pro by using optional function variables. Here, the key is to define the variable to some default in the function, then when you call the function without specifying a value for the variable, the default will be adopted. But if you do specify a value, it will take precedence.

</p><p>Confused? For example, when you connect to a database, you nearly always connect to the same server and you&#8217;ll likely use the same username and password. But sometimes you&#8217;ll need to connect to a different database. Let&#8217;s take a look.

</p>

 <pre class="brush: js"> &lt;html&gt;
 &lt;body&gt;
 &lt;?php

 function  db_connect($host = "localhost", $user="username", $pass="graeme") {

 	$db = mysql_connect($host, $username, $password);

 	return $db;

 }

 $old_db = db_connect();

 $new_host = "site.com";

 $new_db = db_connect($new_host);

 ?&gt;

 &lt;/body&gt;

 &lt;/html&gt;
 </pre>

<p>Isn&#8217;t that cool? The variables used inside the function were defined when the function was defined. The first time the function is called, the defaults are used. The second time, we connect to a new host, but with the same username and password. Great stuff!

</p><p>Think about where you could use other functions in your code. You could use them for data checking, performing routine tasks, and so on. I use them a lot when processing text for display on a Web page. I can check, parse, and modify the text to add new lines and escape HTML characters in one fell swoop.

</p><p>Now all that&#8217;s left to do is to impart some words of wisdom.

</p>

<a name="Closing_Advice"></a><h4> <span class="mw-headline">Closing Advice</span></h4>

<p>When it comes to databasing, there&#8217;s a lot to learn. If you haven&#8217;t done it already, find a good book about database design and learn to put together a solid database &#8211; on any platform. It&#8217;s an invaluable skill and it will save you plenty of time and headache in the long run. Also, learn about MySQL. It&#8217;s a complex but interesting database with a wealth of useful documentation. Learn about table structure, data types, and SQL. You can actually achieve some pretty impressive stuff if you know enough SQL.

</p><p>Finally, there&#8217;s PHP. The PHP Web site has nearly everything you need, from a comprehensive manual to mailing-list archives to code repositories. An excellent way to learn about PHP is to study the examples used in the manual and to check out the code archives. Many of the posted scripts consist of functions or classes that you can use for free in your own scripts without having to reinvent the wheel. Additionally, the mailing list is an excellent spot to check out if you get stuck. The developers themselves read the list and there are plenty of knowledgeable people there who can help you along the way.

</p><p>Good luck and good coding!

</p>

<ul><li><a href="/2010/02/PHP_and_MySQL_Tutorial" title="Tutorial:PHP and MySQL Tutorial"> PHP and MySQL Tutorial</a>

</li><li><a href="/2010/02/PHP_and_MySQL_Tutorial_-_Lesson_1" title="Tutorial:PHP and MySQL Tutorial - Lesson 1"> PHP and MySQL Tutorial &#8211; Lesson 1</a>

</li><li><a href="/2010/02/PHP_and_MySQL_Tutorial_-_Lesson_2" title="Tutorial:PHP and MySQL Tutorial - Lesson 2"> PHP and MySQL Tutorial &#8211; Lesson 2</a>

</li><li><strong class="selflink"> PHP and MySQL Tutorial &#8211; Lesson 3</strong>

</li></ul>

<p><div id='linker_widget' class='contextly-widget'></div>]]></content:encoded>
            <wfw:commentRss>http://www.webmonkey.com/2010/02/php_and_mysql_tutorial_-_lesson_3/feed/</wfw:commentRss>
        <slash:comments>0</slash:comments>

        
    </item>
    
    <item>
        <title>Be Your Own Open ID Provider</title>
        <link>http://www.webmonkey.com/2010/02/be_your_own_openid_provider/</link>
        <comments>http://www.webmonkey.com/2010/02/be_your_own_openid_provider/#comments</comments>
        <pubDate>Tue, 16 Feb 2010 01:45:47 +0000</pubDate>

                <dc:creator>Webmonkey Staff</dc:creator>

        <guid isPermaLink="false">http://stag.wired.com/primate/?p=844</guid>
        		<category><![CDATA[Identity]]></category>
		<category><![CDATA[OpenID]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[wiki]]></category>
        <description><![CDATA[OpenID is a burgeoning standard for identifying and authenticating yourself on the web. You do this by identifying yourself not with a standard username and password, but with a URL. This URL points to a web page that verifies that you are, in fact, you. A number of third-party sites offer OpenID URLs to their [...]]]></description>

            <content:encoded><![CDATA[<!-- wpautop disabled --><p><a href="http://openid.net/" class="external text" title="http://openid.net/" rel="nofollow">OpenID</a> is a burgeoning standard for identifying and authenticating yourself on the web. You do this by identifying yourself not with a standard username and password, but with a URL. This URL points to a web page that verifies that you are, in fact, <b>you</b>.

</p><p>A number of third-party sites offer OpenID URLs to their users, including LiveJournal, AOL, and Technorati. But some people do not like to be beholden to third parties for something that may turn out to be a central part of their online identity, and they&#8217;d rather host their own.

</p><p>An easy way to do that is with an open source PHP identity server called <a href="http://siege.org/projects/phpMyID/" class="external text" title="http://siege.org/projects/phpMyID/" rel="nofollow">phpMyID</a>.

</p><p><br />

<span id="more-844"></span>

</p>

<table id="toc" class="toc" summary="Contents"><tbody><tr><td><div id="toctitle"><h2>Contents</h2> </div>

<ol>

<li><a href="#What_You.27ll_Need">What You&#8217;ll Need</a></li>

<li><a href="#Installing_phpMyID">Installing phpMyID</a></li>

<li><a href="#Using_It">Using It</a></li>



<li><a href="#Further_Reading">Further Reading</a></li>

</ol>

</td></tr></tbody></table>



<a name="What_You.27ll_Need"></a><h2> <span class="mw-headline">What You&#8217;ll Need</span></h2>

<ul><li> A web server running PHP

</li></ul>

<ul><li> An MD5 hashing tool, such as <a href="http://www.rt.com/man/md5sum.1.html" class="external text" title="http://www.rt.com/man/md5sum.1.html" rel="nofollow">md5sum</a> on Unix or <a href="/2010/02/Install_and_Use_Cygwin" title="Tutorial:Install and Use Cygwin"> Cygwin</a> or <a href="http://www.fourmilab.ch/md5/" class="external text" title="http://www.fourmilab.ch/md5/" rel="nofollow">md5.exe</a> on Windows



</li></ul>

<a name="Installing_phpMyID"></a><h2> <span class="mw-headline">Installing phpMyID</span></h2>

<p>Download the latest source from <a href="http://siege.org/projects/phpMyID/" class="external free" title="http://siege.org/projects/phpMyID/" rel="nofollow">http://siege.org/projects/phpMyID/</a>. Create a subdirectory in your web directory called <tt>phpmyid</tt>. Place the files <tt>MyID.config.php</tt> and <tt>MyID.php</tt> in that directory, setting their ownership to the web user, if necessary.

</p><p>In your web browser, go to <a href="http://yourwebserver/phpmyid/MyID.config.php" class="external free" title="http://yourwebserver/phpmyid/MyID.config.php" rel="nofollow">http://yourwebserver/phpmyid/MyID.config.php</a>. The page should display.



</p>

<pre class="brush: js">This is an OpenID server endpoint. For more information, see http://openid.net/



Server: http://yourwebserver/phpmyid/MyID.config.php



Realm: phpMyID



Login

</pre>

<p>If you click the Login link, it&#8217;ll prompt you for a username and password, which you haven&#8217;t yet configured yet. To do that, you need to come up with a username and password, then create an MD5 hash of them.

</p><p><br />

To do this at a Unix command line with OpenSSL, feed the username and password you want to the md5sum utility in the format <tt>username:phpMyID:password</tt>. Replace &#8220;phpMyID&#8221; with the realm from above if your realm differed:

</p>

<pre class="brush: js">echo -n "username:phpMyID:password" | md5sum</pre>

<p><br />

The output will be a 32-character hexadecimal hash that looks like:

</p>

<pre class="brush: js">22a204f0bf622e4a35f3d71304378ca9</pre>

<p>You must memorize this &#8212; Ha, only kidding. Just copy it and be ready to paste it.



</p><p>On Windows, feed the same <tt>username:phpMyID:password</tt> string into the MD5 hasher you&#8217;re using.

</p><p>Now open the file <tt>MyID.config.php</tt> in a text editor. Near the top are two lines:

</p>

<pre class="brush: js">    'auth_username' =&gt;  'test',



    'auth_password' =&gt;  '22a204f0bf622e4a35f3d71304378ca9

</pre>

<p>Replace <tt>'test'</tt> with the username you chose, and replace the 32-character hash that&#8217;s there with the hash you just generated.



</p><p>Now when you click Login, enter your new username and password into the prompt. If you did everything correctly, it should tell you &#8220;You are logged in as username&#8221;.

</p><p><br />

</p>

<a name="Using_It"></a><h2> <span class="mw-headline">Using It</span></h2>

<p>Now, to use this as your OpenID, you&#8217;ll need a URL that points to it. Choose an HTML page under your control &#8212; say, the front page of your site &#8212; or create a new one. Add these two lines inside the <tt>head</tt> of that page:

</p>

<pre class="brush: js">&lt;link rel="openid.server" href="http://yourwebserver/phpmyid/MyID.config.php"&gt;



&lt;link rel="openid.delegate" href="http://yourwebserver/phpmyid/MyID.config.php"&gt;

</pre>



<p><br />

Now, when you want to authenticate, simply give that page&#8217;s URL. It&#8217;ll prompt you for your username and password and then authenticate you.

</p><p><br />

</p>

<a name="Further_Reading"></a><h2> <span class="mw-headline">Further Reading</span></h2>

<p>For additional details, read the phpMyID <a href="https://www.siege.org/svn/oss/phpMyID/trunk/README" class="external text" title="https://www.siege.org/svn/oss/phpMyID/trunk/README" rel="nofollow">README file</a>. This file is also available in the downloaded package.

</p><div id='linker_widget' class='contextly-widget'></div>]]></content:encoded>
            <wfw:commentRss>http://www.webmonkey.com/2010/02/be_your_own_openid_provider/feed/</wfw:commentRss>
        <slash:comments>2</slash:comments>

        
    </item>
    
    <item>
        <title>Drupal&#8217;s Creator Envisions Web Publishing&#8217;s Plug-and-Play Future</title>
        <link>http://www.webmonkey.com/2008/06/drupal_s_creator_envisions_web_publishing_s_plug-and-play_future/</link>
        <comments>http://www.webmonkey.com/2008/06/drupal_s_creator_envisions_web_publishing_s_plug-and-play_future/#comments</comments>
        <pubDate>Thu, 19 Jun 2008 22:29:01 +0000</pubDate>

                <dc:creator>Michael Calore</dc:creator>

        <guid isPermaLink="false">http://www.webmonkey.com/blog/drupalscreatorenvisionswebpublishingsplugandplayfuture</guid>
        		<category><![CDATA[Business]]></category>
		<category><![CDATA[Software & Tools]]></category>
		<category><![CDATA[CMS]]></category>
		<category><![CDATA[drupal]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[PHP]]></category>
        <description><![CDATA[Dries Buytaert started down his path to fame when he coded up a private message board for his college dormitory. Nine years later, that modest bulletin board software package has grown into Drupal, one of the most popular open-source content publishing systems on the web with thousands of active contributors. In March 2008, Buytaert connected [...]]]></description>

            <content:encoded><![CDATA[<p><!-- wpautop enabled -->
<p><img class="blogimg" src="http://howto.wired.com/mediawiki/images/Dries_acquia_630.jpg" alt="Dries Buytaert CTO of Acquia and Drupal project lead" title="Dries Buytaert CTO of Acquia and Drupal project lead" class="full" /></p>
<p>Dries Buytaert started down his path to fame when he coded up a private message board for his college dormitory. Nine years later, that modest bulletin board software package has grown into <a href="http://drupal.org/">Drupal</a>, one of the most popular open-source content publishing systems on the web with thousands of active contributors. In March 2008, Buytaert connected with entrepreneur Jay Batson, and together the two of them founded <a href="http://acquia.com/">Acquia</a>, a commercial venture that will provide technical support for Drupal&#8217;s devotees as well as further the adoption and development of the platform.</p>
<p>Webmonkey sat down with Dries and Jay to talk about the history of Drupal, where development is headed and the role their new company will play in the project&#8217;s future.</p>
<p><em>Photos: Jim Merithew/Wired</em></p>
<p><strong>Webmonkey:</strong> Dries, can you give us Drupal&#8217;s back-story? The germ of the idea and how the platform grew into existence?</p>
<p><strong>Dries Buytaert:</strong> It sort of happened by accident. I was a student at the University of Antwerp in Belgium around 1999. I was doing web development with CGI and server-side includes, but I wanted to learn more about technologies like PHP and MySQL. Also, at the same time, we had the need for an internal messaging system at our student dorm. So, I wrote a simple message board. Then when I graduated, I decided to move my internal message board onto the internet.</p>
<p>When I registered a domain for it, I wanted to register the name &#8220;Dorp,&#8221; which is Dutch for &#8220;small village.&#8221; But I mis-typed, and actually ended up registering the name Drop. Amazingly, Drop.org was still available, and since it&#8217;s an English word with multiple meanings, I decided to just go with it.</p>
<p>Our original user community died pretty quickly, but I continued working on it by adding things like RSS feeds and the ability for users to rate content. More and more people started coming to the site with ideas and suggestions, like ways to modify the algorithm that handles comment moderation. At a certain point, I was getting so many suggestions that I decided to just open up the source code. That was the Drupal 1.0 release, which came out in early 2001.</p>
<p>At the time of the release, I was fairly confident that I had a good system. I felt that it was competitive with the other open source technologies out there like PHP-Nuke. So, it felt like the right thing to do.</p>
<p><strong>Webmonkey:</strong> One of the key pieces of Drupal&#8217;s design is its modularity &#8212; users install a core package, then add functionality by installing task-specific modules. Where did the idea for the modular design originate?</p>
<p><strong>Buytaert:</strong> It was part of the initial design. I was sort of shocked that most of the other systems didn&#8217;t have a modular design &#8212; to me, with my background as a computer science student, that felt like a very natural thing to do. I was also involved in the Linux kernel back then, working on wireless network drivers. That&#8217;s also obviously a modular system, so I may have gotten some inspiration from there as well.</p>
<p><a href="http://howto.wired.com/mediawiki/images/Dries_jay_acquia_630.jpg" border="0"><img class="blogimg" src="http://howto.wired.com/mediawiki/images/Dries_jay_acquia.jpg" title="Buytaert and Batson CLICK FOR LARGER" alt="Buytaert and Batson CLICK FOR LARGER" border="0" /></a><strong>Jay Batson:</strong> Speaking as somebody who dealt with a lot of content management systems before meeting Dries, I can say that most of the other CMS&#8217;s out there didn&#8217;t come from people who were computer science grad-types. They were built by web designers or programmers who maybe were self-taught and had hacked together a system that sort of worked. They didn&#8217;t come from people with an underlying discipline of computer science. That ended up being a key distinction between Drupal and other systems.</p>
<p><strong>Webmonkey:</strong> Drupal is especially popular with those who want to build a site around some sort of central social networking component. Is that because it gives such granular control over user management, or is it because Drupal became popular at the same time social networks were really taking off?</p>
<p><strong>Buytaert:</strong> I think the first reason is definitely a big part of it. Drupal was a multi-user system from day one, but most of the other systems are behind Drupal as far as user management and access rights.</p>
<p>It&#8217;s a very social system by design. For example, the original Drop.org site was very much like Digg, where people could submit links and vote on each other&#8217;s submissions. Such user interaction was a key initial feature of Drupal. Over time, we&#8217;ve been moving away from these features. That voting system has since been taken out of the core, but it&#8217;s available in a module. Instead we&#8217;re evolving into a platform that can do more &#8212; the traditional web content management stuff as well as the social stuff.</p>
<p><strong>Batson:</strong> They also got a good boost because Drupal 5 had as its tag line &#8220;Community Plumbing.&#8221; At that moment in time when community-based sites were becoming more important, here was this system marketing itself as being optimized for that.</p>
<p>Also at that time, there were a lot of people coming into the Drupal community and contributing code. So, a great deal of code was written in that area with the social features in mind. I know Dries was spending most of his time during that period managing those contributions &#8212; keeping the Drupal core slim, but making sure that the key features were there. And, at the same time, stressing the importance of modules.</p>
<p><strong>Buytaert:</strong> One of the things I&#8217;ve always encouraged people to do was take Drupal in different directions. I think it&#8217;s a very powerful notion to get out of people&#8217;s way. So if they want to build a social networking site or a Flickr clone, I think it&#8217;s important that Drupal as a platform is capable of serving all these different needs. That&#8217;s what the modular design helps accomplish.</p>
<p><strong>Webmonkey:</strong> Tell us about Acquia, the company you founded together.</p>
<p><strong>Batson:</strong> Our goal is to become to Drupal what Red Hat and Canonical are to Linux. If you want a supported version of this open-source software, you come to us and pay a subscription. You get a distribution, a set of services for maintenance and updates plus access to our tech support center. So let&#8217;s say you&#8217;re running a large-scale media site and you&#8217;ve built all of your front-end infrastructure on Drupal. You need an answer about something, and you want the ability to pick up the phone and have an answer within an hour rather than send an e-mail and wait a day, or wait for the appropriate person to log in on IRC. On the other end of the spectrum is the small site that needs help with installing modules or managing updates. It&#8217;s a well-proven open-source business model.</p>
<p>The other role we can play at Acquia is supporting the Drupal development community. Drupal has wonderful organic growth. The community is roughly doubling every year. That&#8217;s impressive, but we&#8217;d like to see it grow by a factor of ten.</p>
<p><strong>Webmonkey:</strong> How many developers are working on Drupal right now?</p>
<p><strong>Buytaert:</strong> For Drupal 6, the last major release, we had around 900 people contribute to the core. As a reference, that&#8217;s the same number of people who contribute to the Linux kernel. There are over 2,000 contributed modules, and each of these modules has one or more maintainers. The Drupal.org website has between 250,000 and 300,000 registered users. These are not necessarily all developers, but those people are participating in the community in some way.</p>
<p><strong>Webmonkey:</strong> Where is Drupal development going next?</p>
<p><strong>Buytaert:</strong> We are working on Drupal 7 right now. We&#8217;ll have a better database abstraction layer, better support for WYSIWYG tools and usability improvements for admins that make it easier to configure Drupal.</p>
<p>We have a new core feature called Content Construction Kit, or CCK. This lets you define new types of content using a web interface. For example, if you have a bicycle website and you want your users to be able to share their favorite rides, you can create a new content type called &#8220;rides.&#8221; That content type might include a start location, an end location, a link to a Google map, some pictures of the route, text describing the ride. Once you have all of this data, you can choose to visualize the ride on a Google map, or display it all in a table or whatever you want. Many different views can be extracted from this big bag of user data, and it can all be accomplished using an easy web interface.</p>
<p>Our long-term vision for Drupal as an open-source project to fully democratize online publishing &#8212; to make it possible for everyone to create really powerful and interesting websites just by clicking around. Drupal lets you get a working prototype up and running in just a couple of hours without having to write any code. That&#8217;s very powerful.</p>
<div id='linker_widget' class='contextly-widget'></div>
]]></content:encoded>
            <wfw:commentRss>http://www.webmonkey.com/2008/06/drupal_s_creator_envisions_web_publishing_s_plug-and-play_future/feed/</wfw:commentRss>
        <slash:comments>1</slash:comments>

        
    </item>
    </channel>
</rss>
