PHP
  Home arrow PHP arrow Making Changes in a Project Management Application
Dev Shed Forums  
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Smartphone Development  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Mobile Linux  
App Generation ROI  
IBM® developerWorks  
Forums Sitemap  
E-Commerce Hosting  
Linux Web Hosting  
Managed Hosting  
Small Business Hosting  
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? 
Google.com  
PHP

Making Changes in a Project Management Application
By: David Web
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: starstarstarstarstar / 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:
      error-file:tidyout.log Del.ici.ous error-file:tidyout.log Digg
      error-file:tidyout.log Blink error-file:tidyout.log Simpy
      error-file:tidyout.log Google error-file:tidyout.log Spurl
      error-file:tidyout.log Y! MyWeb error-file:tidyout.log 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

    - Implementing Factory Methods in PHP 5
    - Merging a File Split for FTP Upload using PHP
    - Getting Data from Yahoo Site Explorer Inboun...
    - Method Chaining: Adding More Selecting Metho...
    - How to Split a File During an FTP Upload Usi...
    - Expanding a Custom CodeIgniter Library with ...
    - Using the Yahoo Site Explorer Inbound Links ...
    - Building a CodeIgniter Custom Library with M...
    - Building an E-mini Trading System Using PHP ...
    - Completing the MySQL Class with Method Chain...
    - Building Dynamic Queries with Chainable Meth...
    - PHP Encryption and Decryption Methods
    - Building a MySQL Abstraction Class with Meth...
    - Completing a Sample String Processor with Me...
    - Mastering WHILE Loops for PHP and MySQL





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