PHP
  Home arrow PHP arrow Making Changes in a Project Management...
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 
Moblin 
JMSL Numerical Library 
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


    (Page 1 of 4 )

    This is the third part of a seven part article series detailing the creation of a project management application. It will discuss how to make changes to the project, such as the project's status, via the edit_project.php script.

    The next script that we will be looking at is the edit_project.php script. It is responsible for handling any changes that you want to make to a project. It has exactly the same form layout as the add_project.php script, except it needs to do a retrieve and update query. The reason for retrieving the project information in the first place is to display that information in a form. This way you know and see exactly what you want to change.

    For example, if the project name is 'ProjectX' and you want to change it to 'My Project,' then all you do is delete the 'Project X' name and add the 'My Project' name to that field. It just makes the chances of someone making the wrong entry very slim. Once you have changed the things you want, you simply click on the update button and the update query will spring into action. Below is a screen shot of what the edit_project page looks like:


    Below is the entire code for this page:

    <?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:


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

    //clean pid

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

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

    header("location:login.php");

    }


    //otherwise clean the received 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);

    }



    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'];

    }


    //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

    ?>


    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

    <html xmlns="http://www.w3.org/1999/xhtml"><!-- InstanceBegin template="/Templates/PM_Main.dwt.php" codeOutsideHTMLIsLocked="false" -->

    <head>

    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />

    <!-- InstanceBeginEditable name="doctitle" -->

    <title>Untitled Document</title>

    <!-- InstanceEndEditable -->

    <!-- InstanceBeginEditable name="head" --><!-- InstanceEndEditable -->

    <link href="Templates/main.css" rel="stylesheet" type="text/css" />

    </head>


    <body>

    <table width="100%" border="0">

    <tr>

    <td width="33%">&nbsp;</td>

    <td width="28%">&nbsp;</td>

    <td width="39%">Logged in: <!-- InstanceBeginEditable name="login" --><? echo $_SESSION['name'];?> | <a href="logout.php">Logout</a><!-- InstanceEndEditable --></td>

    </tr>

    <tr>

    <td colspan="3" bgcolor="#6699CC" class="headertxt">Project Management Software </td>

    </tr>

    <tr>

    <td colspan="3"><!-- InstanceBeginEditable name="main" -->

    <form id="form1" name="form1" method="post" action="edit_project.php" enctype="multipart/form-data">

    <table width="100%" border="0">

    <tr>

    <td width="12%">proj name </td>

    <td width="88%">&nbsp;</td>

    </tr>

    <tr>

    <td>Title</td>

    <td><label>

    <input name="title" type="text" id="title" value="<?php echo $projectdetails['title']?>"/>

    </label></td>

     

    </tr>

    <tr>

    <td>Description</td>

    <td><label>

    <textarea name="descr" id="descr"><?php echo $projectdetails['project_description']?></textarea>

    </label></td>

    </tr>

    <tr>

    <td>Status</td>

    <td><label>

    <select name="status" id="status">

    <?php

    $list=array('overdue','completed','pending');

    switch($projectdetails['status']){

     

    case "overdue":

    echo "<option value='overdue'

    selected";

     

    break;

    case "completed":

    echo "<option value='completed'

    selected";

     

    break;

    case "pending":

    echo "<option value='pending'

    selected";

     

    break;

    }

    for($x=0; $x < 4; $x++){

    echo ">" .$list[$x]. "</option>";

    }

    ?>

    </select>

    <input type="hidden" name="p_pid" value="<?php echo $_GET['pid']?>"/>

    </label></td>

    </tr>

    <tr>

    <td>Date Due </td>

    <td><label>

    <?

    $dd = date("d");

    $mm = date("m");

    $yy = date("Y");

    echo "<select name="dd">n";

    for($i = 1; $i <= 31; $i++) {

    echo "<option value="" . $i . """;

    if($i == $dd) {

    echo " selected";

    }

    echo ">" . $i . "</option>n";

    }

    echo "</select>&nbsp;<select name="mm">n";

    for($i = 1; $i <= 12; $i++) {

    echo "<option value="" . $i . """;

    if($i == $mm) {

    echo " selected";

    }

    echo ">" . $month_names[$i] . "</option>n";

    }

    echo "</select>&nbsp;<select name="yy">n";

    for($i = $yy; $i <= ($yy + 1); $i++) {

    echo "<option value="" . $i . """;

    if($i == $yy) {

    echo " selected";

    }

    echo ">" . $i . "</option>n";

    }

    echo "</select>";

    ?>

    <input type="hidden" name="createdt" value="<?php echo $projectdetails['create_dt']?>" />

    </label></td>

    </tr>

    <tr>

    <td>&nbsp;</td>

    <td><label>

    <input name="submit" type="submit" id="submit" value="Update!" />

    </label></td>

    </tr>

    </table>


    </form>

    <!-- InstanceEndEditable --></td>

    </tr>

    <tr>

    <td colspan="3"><!-- InstanceBeginEditable name="nav" --><table width="100%" border="0">

    <tr>

    <td><a href="edit_task.php?pid=<?php echo $projectdetails['pid'];?>">Change a Task in this Project</a> | <a href="edit_staff.php?pid=<?php echo $projectdetails['pid'];?>">Change Staff members of this Project </a> | <a href="main.php">View Project List</a> | <a href="admin/login.php">Administrators Corner </a> </td>

    </tr>

    </table><!-- InstanceEndEditable --></td>

    </tr>

    <tr>

    <td align="right" class="cright" colspan="3">copyright &copy; 2007 PM </td>

    </tr>

    </table>

    </body>

    <!-- InstanceEnd --></html>

    More PHP Articles
    More By David Web


     

       

    PHP ARTICLES

    - Building a Database-Driven Application with ...
    - User Authentication for a Project Management...
    - Introduction to the CodeIgniter PHP Framework
    - Adding Users for a Project Management Applic...
    - Migrating Class Code for a MIME Email to PHP...
    - Login and Logout Authentication for a Projec...
    - Composing Messages in HTML for MIME Email wi...
    - Project Management: Authentication
    - A Better Way to Determine MIME Types for MIM...
    - Project Management Overview
    - Handling Attachments in MIME Email with PHP
    - Completing the Project Management Application
    - Sending MIME Email with PHP
    - Handling Files for a Project Management Appl...
    - Viewing and Editing Tasks for a Project Mana...





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