MySQL
  Home arrow MySQL arrow Page 3 - Online Photo Album Development using P...
Dev Shed Forums 
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Forums Sitemap 
IBM® developerWorks 
Sun Developer Network 
Dedicated Servers 
E-Commerce Hosting 
Linux Web Hosting 
Managed Hosting 
Small Business Hosting 
Actuate Whitepapers 
VeriSign Whitepapers 
VPS Hosting 
Weekly Newsletter

 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
MYSQL

Online Photo Album Development using PHP and GD: Part 2
By: Frank Manno
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 3 stars3 stars3 stars3 stars3 stars / 31
    2004-04-22

    Table of Contents:
  • Online Photo Album Development using PHP and GD: Part 2
  • Code: Explained
  • Configurating
  • Connecting to the Database
  • 1,2,3, Testing

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT

    Generate data entry and reporting .NET Web apps in minutes, straight from your database. Read our FREE whitepaper “Build Web 2.0 Applications Without Hand-Coding” Download now!

    Online Photo Album Development using PHP and GD: Part 2 - Configurating


    (Page 3 of 5 )

    Our config file initializes our connection variables: $db_server, $db_user, $db_pass, and $db_name. These variables are used in the db_connect() function which simply connects to our database system (in this case MySQL) and selects the album database we'll be using in our application.

    Our create_album.php file is simply a form that accepts user-input, and submits the data to our processing script. Once the data is entered by the user, our processor script checks to see if all the fields have been completed; if not, an error message is displayed. If all fields are complete, the album data is added to the database. We'll call our processor script add_album.php:

     
    <p><!--p<-->include_once("../include/config.php"); 
    <
    br />// Verify that all form elements are completed 
    <br />if (empty($_POST['album_name']) || empty($_POST['album_desc'])){ 
    <
    br />displayPage("Please complete all required fields! 
    <br /><a href="
    /administrator/'new_album.php'">Go Back</a>""Error Adding Album!"); 
    <
    br />die(); 
    <
    br />} 
    <
    br />// Connect to database 
    <br />db_connect(); 
    <
    br />$sql "INSERT INTO albums VALUES(0, '" addslashes($_POST['album_name']) . 
    "', '" addslashes($_POST['album_desc']) . "', 0, '', '')"
    <
    br />$result = @mysql_query($sql) or die("Error inserting record: " mysql_error()); 

    <
    br />if ($result){ 
    <
    br />// Notify use that album was successfully created. 
    <br />$msg .= "Album <strong>" $_POST['album_name'] . "</strong> successfully created!"
    <
    br />$msg .= 
    <br /><a href="
    /administrator/'edit_album.php?album_id=">Click here</a> to administrate the " . $_POST['album_name'] . " album"; 
    <br />$msg .= " </p>
    <p><a href="/administrator/'
    index.php'">Click here</a> to return to the administrative area</p>"; 
    <br />displayPage($msg, "Album " . $_POST['
    album_name'] . "Added!"); 
    <br />} 
    <br />

     
    <p> </p>"; displayPage($msg, "Album " . $_POST['
    album_name'] . "Added!"); } 

    ";displayPage($msg, 
    "Album " . $_POST['
    album_name'] . "Added!");}

     
    <p>Here'
    s a breakdown of the code:</p>
    <
    p>include_once("../include/config.php"); 
    <
    br />// Verify that all form elements are completed 
    <br />if (empty($_POST['album_name']) || empty($_POST['album_desc'])){ 
    <
    br />displayPage("Please complete all required fields! 
    <br /><a href="
    /administrator/'new_album.php'">Go Back</a>""Error Adding Album!"); 
    <
    br />die(); 
    <
    br />}</p>

    The include line, again, is to make use of the global variables and function that allow us to connect to the database.

    >

    More MySQL Articles
    More By Frank Manno


     

       

    MYSQL ARTICLES

    - MySQL Table Prefix Changer Tool in PHP
    - Using the SIGNAL Statement for Error Handling
    - Error Handling Examples
    - Error Handling
    - Completing a Search Engine with MySQL and PH...
    - Paginating Result Sets for a Search Engine B...
    - Building a Search Engine with MySQL and PHP 5
    - Using Boolean Operators for Full Text and Bo...
    - PHP, MySQL and the PEAR Database
    - Working with PHP and MySQL
    - Getting PHP to Talk to MySQL
    - Creating an RSS Reader: the Reader
    - MySQL Security Overview
    - Creating the Admin Script for a PHP/MySQL Bl...
    - Creating the Blog Script for a PHP/MySQL Blo...





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway