PHP
  Home arrow PHP arrow Page 2 - Making Changes in a Project Management...
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 
E-Commerce Hosting 
Linux Web Hosting 
Managed Hosting 
Small Business Hosting 
Mobile Linux 
App Generation ROI 
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? 
PHP

Making Changes in a Project Management Application
By: David Web
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 3
    2008-06-16

    Table of Contents:
  • Making Changes in a Project Management Application
  • PHP Explained
  • HTML Form
  • Determining the Value of the Variable

  • 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


    Making Changes in a Project Management Application - PHP Explained


    (Page 2 of 4 )


    Let's take a closer look at the PHP section of the code. The HTML is not so difficult to understand, so I will just review it briefly later on.

    The first part, as always, includes the functions and dbcon.php files. It then has a place to initialize variables:


    <?php

    include "dbcon.php";

    include "functions.php";

    //initialise variables

    $alert =false;

    // retrieve information based on the user id, that we set in the login page:


    The project id variable that is received is checked to see if it is a number. If it is not a number, then we know someone has tampered with it and we need to redirect the user to the login page:


    if(isset($_GET['pid'])){

    //clean pid

    if(!is_numeric($_GET['pid'])){

    //the value recieved is not numeric. redirect the user to login

    header("location:login.php");

    }


    If all is well, we continue to retrieve the project details and store them in the $projectdetails variable:


    //otherwise clean the recieved value for query use

    //get projects

    $projectID = mysql_escape_string($_GET['pid']);

    $getproject= "SELECT * FROM projects WHERE pid = '".$projectID."'";

    $results = mysql_query($getproject);

    $projectdetails = mysql_fetch_assoc($results);

    }

    The code checks to see if the form has been submitted. This would indicate that the user has made his or her changes and is now ready to update the project details:


    if(isset($_POST['submit'])){


    //clean vars

    $title = mysql_escape_string($_POST['title']);

    $descr= mysql_escape_string($_POST['descr']);

    $status =mysql_escape_string($_POST['status']);

    $createdt = mysql_escape_string($_POST['createdt']);

    $p_pid = mysql_escape_string($_POST['p_pid']);


    //build date

    $duedt = $_POST['yy'] . "-";

    if($_POST['mm'] < 10) {

    $duedt .= "0";

    }

    $duedt .= $_POST['mm'] . "-";

    if($_POST['mm'] == 4 || $_POST['mm'] == 6 || $_POST['mm'] == 9 || $_POST['mm'] == 11) {

    if($_POST['dd'] > 30) {

    $duedt .= "30";

    } else {

    $duedt .= $_POST['dd'];

    }

    } elseif($_POST['mm'] == 2) {

    if($_POST['yy'] == 2008 || $_POST['yy'] == 2012) {

    if($_POST['dd'] > 29) {

    $duedt .= "29";

    } else {

    $duedt .= $_POST['dd'];

    }

    } else {

    if($_POST['dd'] > 28) {

    $duedt .= "28";

    } else {

    $duedt .= $_POST['dd'];

    }

    }

    } else {

    $duedt .= $_POST['dd'];

    }

    We run an update query and update the project's table:


    //update

    $query = "UPDATE projects SET title='" .$title. "', ";

    $query .= "project_description='" . $descr. "', status='" .$status . "',due_dt='" .$duedt."',";

    $query .= "create_dt='" . $createdt. "', u_id='" .$_SESSION['uid'] . "'";

    $query .= " WHERE pid='" .$p_pid. "'";

    $result=mysql_query($query);

    if(!$result){

    echo mysql_error();

    }else{

    header("location:main.php");

    }


    }//submit

    ?>

    More PHP Articles
    More By David Web


     

       

    PHP ARTICLES

    - Working With Different Namespaces in PHP 5
    - User Management Explained: Overview
    - Using Namespaces in PHP 5
    - Database Security: Guarding Against SQL Inje...
    - Building a Modular Exception Class in PHP 5
    - Database and Password Security for Web Appli...
    - Handling MySQL Data Set Failures in PHP 5
    - Building Site Registration for Web Applicati...
    - Intercepting Customized Exceptions in PHP 5
    - Securing Your Web Application Against Attacks
    - Sub Classing Exceptions in PHP 5
    - Authentication for Web Application Security
    - Building a Content Management System with Co...
    - Filters and Login Systems for Web Applicatio...
    - Working with the Email Class in Code Igniter





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway
    Stay green...Green IT