Database Code
  Home arrow Database Code arrow PHP & MySQL Tagboard
Codewalker Forums 
  Tutorials  
Database Articles  
Miscellaneous  
Navigation Usability  
PEAR Articles  
Programming Basics  
Server Administration  
XML Tutorials  
  Reviews  
Database Book Reviews  
Linux Book Reviews  
Miscellaneous Reviews  
PHP Book Reviews  
PHP Software Reviews  
Server Admin Reviews  
SQL Tool Reviews  
  Code Gallery  
Content Management Code  
Contest Code  
Counters Code  
Database Code  
Date Time Code  
Discussion Board Code  
Email Code  
File Manipulation Code  
GUI Code  
Link Farm Code  
Miscellaneous Code  
Search Code  
Site Navigation Code  
User Management Code  
Mobile Linux 
Case Studies 
iPad Development 
Download TestComplete 
Forums Sitemap 
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? 
DATABASE CODE

PHP & MySQL Tagboard
By: Codewalkers
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 3
    2002-05-27

    Table of Contents:

    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


    A simple yet efficient tagboard written in PHP with a MySQL back-end.

    By : ipx

    HTML for tagboard:
    <iframe src='view.php' border='0' name='tagboard'></iframe><br>
    <form action='post.php' method='post' target='tagboard'>
    <input type='text' name='name' value='name'><br>
    <input type='text' name='http' value='http://'><br>
    <input type='text' name='msg' value='message'><br>
    <input type='submit' value='Submit'> <input type='reset' value='Reset'>
    </form>

    --post.php--
    <?php
    #change localhost to the sql server, user to the correct username, and pass to the correct password
    $con = mysql_connect("localhost","user","pass") or die("Unable to establish a connection to the database.");

    #change database to the database name
    $database = "database";
    $db = mysql_select_db("$database") or die("Couldn't select database $database.");

    #lets strip some chars and slashes
    $name = stripslashes($name);
    $name = htmlspecialchars($name);
    $http = stripslashes($http);
    $http = htmlspecialchars($http);
    $msg = stripslashes($msg);
    $msg = htmlspecialchars($msg);

    $query = "INSERT INTO tagboard(name,http,msg)
    VALUES('$name,$http,$msg')";

    $result = mysql_query($query) or die("Data couldn't be entered into the database.");

    echo "Click <a href='view.php'>here</a>.";
    ?>

    --view.php--
    <?php
    #change localhost to the sql server, user to the correct username, and pass to the correct password
    $con = mysql_connect("localhost","user","pass") or die("Unable to establish a connection to the database.");

    #change database to the database name
    $database = "database";
    $db = mysql_select_db("$database") or die("Couldn't select database $database.");

    $query = "SELECT id,name,http,msg FROM tagboard ORDER BY id DESC"; selects all the rows from the table tagboard and orders them in descending order

    $result = mysql_query($query);
    while ($rows = mysql_fetch_row($result))//a loop
    {
    echo "<a href='$row[http]' target='_blank'>$row[name]</a>: $row[msg]<br>";
    }
    ?>

    --admin.php--
    <?php
    /*$PHP_AUTH_USER != 'user' is the username setting & $PHP_AUTH=PW !='open' is the password setting*/

    if ( ( !isset( $PHP_AUTH_USER )) || (!isset($PHP_AUTH_PW))
    || ( $PHP_AUTH_USER != 'user' ) || ( $PHP_AUTH_PW != 'open' ) ) {

    //name of the realm or protected area.
    header( 'WWW-Authenticate: Basic realm="Tagboard Administration"' );

    header( 'HTTP/1.0 401 Unauthorized' );

    /*when authorization fails*/
    echo "Authorization Required.";
    exit;

    }
    else {
    /*Function used to connect to sql server and choose database*/
    function connect(){
    #change localhost to the sql server, user to the correct username, and pass to the correct password
    $con = mysql_connect("localhost","user","pass") or die("Unable to establish a connection to the database.");

    #change database to the database name
    $database = "database";

    $db = mysql_select_db("$database") or die("Couldn't select database $database.");
    }
    echo "Tagboard Administration <br> <a href='admin.php?action=view'>View messages
    </a> <a href='admin.php?action=delall'>Delete all messages</a> <a href='admin.php?action=update'><br><br>";
    if($action == "view"){
    connect();
    $query = "SELECT id,name,http,msg FROM tagboard ORDER BY id DESC";
    $result = mysql_query($query);
    while ($rows = mysql_fetch_row($result)){
    echo "<a href='$row[http]' target='_blank'>$row[name]</a>: $row[msg] : <a href='admin.php?action=del&id=$row[id]'>Delete</a><br>";
    }
    }
    if($action == "del"){
    connect();
    $query = "DELETE FROM tagboard WHERE id='$id'";
    $result = mysql_query($query);
    }
    if($action == "delall"){
    connect();
    $query = "DELETE FROM tagboard";
    $result = mysql_query($query);
    }
    if($action == "update"){
    connect();
    $query = "SELECT id,name,http,msg FROM tagboard ORDER BY id DESC";
    $result = mysql_query($query);
    while ($rows = mysql_fetch_row($result)){
    echo "<a href='$row[http]' target='_blank'>$row[name]</a>: $row[msg] : ID#: $row[id]<br>";
    }
    echo "<br>
    <form action='admin.php?action=update&go=yes' method='post'>
    <input type='text' name='id' value='ID #'><br>
    <input type='text' name='name' value='Name'><br>
    <input type='text' name='http' value='http://'><br>
    <textarea name='msg'>Message</textarea><br>
    <input type='submit' value='Submit'> <input type='reset' value='Reset'>
    </form>";
    }
    if($go == "yes"){
    connect();
    $id = stripslashes($id);
    $id = htmlspecialchars($id);
    $name = stripslashes($name);
    $name = htmlspecialchars($name);
    $http = stripslashes($http);
    $http = htmlspecialchars($http);
    $msg = stripslashes($msg);
    $msg = htmlspecialchars($msg);

    $query = "UPDATE tagbard WHERE id='$id' SET name='$name' http='$http' msg='$msg'";
    $result = mysql_query($query);
    echo "ID # $id has been edited successfully.";
    }
    }
    ?>

    --sql syntax--
    CREATE TABLE tagboard (id TINYINT (4) not null AUTO_INCREMENT, name VARCHAR (32), msg VARCHAR (50), http VARCHAR (32) , PRIMARY KEY (id))
    DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

    More Database Code Articles
    More By Codewalkers

     

    IBM® developerWorks developerWorks - FREE Tools!


    Build Forge Express demo: Enabling software delivery excellence for small and midsized businesses

    This demonstration gives you an overview of IBM® Rational® Build Forge Express Edition, a global offering that provides a framework to automate and execute software processes. Rational Build Forge provides a software assembly line that can support all of your tools, technologies, and platforms so you can achieve a repeatable, reliable, and traceable build and release process.
    FREE! Go There Now!


    NEW! Best Practices: The Integrated Project and Portfolio Management Platform.

    Hear how IBM Rational Project and Portfolio Management integrated solutions help teams put the right tools and processes in place to maximize the effectiveness and efficiency of project teams and ensure that the business vision is being executed correctly. Learn how to automate and integrate requirements prioritization, top-down project planning, communications and controls, and methodology deployment to keep your scope, costs, and schedules under control. Tackle with an end-to-end approach the management of scope and scope changes, usage of methodology to control and empower project teams, and optimization of resources to align activity costs with the overall project plan.
    FREE! Go There Now!


    NEW! Cook up Web sites fast with CakePHP, Part 4: Use CakePHP&apos;s Session and Request Handler components

    CakePHP is a stable production-ready, rapid-development aid for building Web sites in PHP. This "Cook up Web sites fast with CakePHP" series shows you how to build an online product catalog using CakePHP.
    FREE! Go There Now!


    NEW! Download DB2 Express-C 9.5

    Visit IBM developerWorks to download IBM DB2 Express-C 9.5, a no-charge version of DB2 Express 9 database server. DB2 Express-C offers the same core data server base features as other DB2 Express editions and provides a solid base to build and deploy applications developed using C/C++, Java, .NET, PHP, and other programming languages.
    FREE! Go There Now!


    NEW! Hacking 101

    Join us for this web seminar to learn how you can defend your web applications from attack. Learn about the 3 most common web application attacks, including how they occur and what can be done to prevent them. We’ll also discuss manual versus automated approaches for scanning and identifying web application vulnerabilities and how IBM Rational AppScan, an automated vulnerability scanner, can help you automate more of what you are doing manually today.
    FREE! Go There Now!


    NEW! Software Change and Configuration Management Solution Guidelines

    This whitepaper provides areas to consider when evaluating any software configuration management solution. It addresses how the IBM solutions (Rational ClearCase and Rational ClearQuest) meet the needs and requirements of both project leaders and developers to provide successful Software Change and Configuration Management.
    FREE! Go There Now!


    NEW! Successful Change and Release Management for .NET

    Join this webcast to discover the key requirements for successful change and release management. Learn how to extend your .NET environment to improve productivity and collaboration, and address core problems afflicting team development. In this webcast, we’ll review typical challenges faced by customers and how to resolve them with the IBM Rational Change and Release Management solution, including Rational ClearCase, Rational ClearQuest and Rational Build Forge. Replay is available for 9 months.
    FREE! Go There Now!


    NEW! Trial download: IBM Lotus Forms V3.0

    Get a free trial download of IBM Lotus Forms V3.0 (formerly Workplace Forms), which provides a zero-footprint eForms solution to help you automate and move forms-based business processes off the desktop and onto the Web. With Lotus Forms, you can extend applications beyond the firewall by creating a single electronic form document ready for use in both thick and Web 2.0 thin client format.
    FREE! Go There Now!


    NEW! Trial download: IBM Rational Manual Tester V7.0.1

    Try the latest version of IBM Rational Manual Tester V7.0.1 by downloading a free trial from IBM developerWorks. This manual test authoring and execution tool promotes test step reuse to reduce the impact of software change on testers and business analysts and addresses the needs of teams performing at least a portion of their testing manually.
    FREE! Go There Now!


    NEW! Webcast: WebSphere Process Server

    WebSphere Process Server delivers a unique integration framework that simplifies existing IT resources. Often, as IT assets grow to support business demand, so too does their complexity and manageability. In this webcast, we’ll discuss how WebSphere Process Server helps deliver an SOA infrastructure that provides a common model to orchestrate, mediate, connect, map, and execute the underlying IT functions. Discover how WebSphere Process Server simplifies integration of business processes by leveraging existing IT assets as reusable services without the complexities of traditional integration methodologies.
    FREE! Go There Now!



    All FREE IBM® developerWorks Tools!

    DATABASE CODE ARTICLES

    - Converting CSV Files to MySQL Insert Queries...
    - Examples and Tools for Database Design
    - Relationships, Entities and Database Design
    - Modeling and Designing Databases
    - Data extract to Excel
    - Oracle database class 0.76
    - The opposite of mysql_fetch_assoc
    - On line Thermal Transmitance Calculation
    - pjjTextBase
    - PHP Object Generator
    - FastMySQL
    - RC4PHP
    - SQL function with integrated sprintf()
    - DB Interaction Classes v1.1
    - deeMySQLParser





    © 2003-2010 by Developer Shed. All rights reserved. DS Cluster 12 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek