SitePoint Sponsor

User Tag List

Results 1 to 24 of 24

Thread: $_GET help!!

  1. #1
    SitePoint Zealot
    Join Date
    Feb 2005
    Posts
    109
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    $_GET help!!

    i have an excerpt of my code here...

    in the viewform code, i have an edit link and the code is like this

    PHP Code:
    $editquery "SELECT userID, projectID FROM projects WHERE userID='$uid' AND projectID='$id'";
    $editresult = @mysql_query($editquery) or die(mysql_error());
    if (
    mysql_fetch_assoc($editresult))
    {
       
    $edit '<a href="projectedit.php?eid='.$_GET['pid'].'" class=under>EDIT</a>';
    }
    else
    {
       
    $edit '&nbsp;';

    then in my edit page

    PHP Code:
    $id $_SESSION['userID'];
    $eid $_GET['eid'];
     
    if (isset(
    $_POST['submit']))
    {
    ...
    some codes here...

    then i have a database query

    PHP Code:
    $query "UPDATE posts SET projecttitle='$pt', companyrole='$r', location='$l', description='$d', 
            objective='
    $o', justification='$j', startdate='$sd', enddate='$ed', leadfirm='$lf', cosponsoringfirm='$csf', 
            delegateddepartment='
    $dd', assignedperson='$ap', type='$t', category='$c', contactperson='$cp', 
            expectedresult='
    $er', userID='$id', postupdate=NOW() WHERE userID='$id' AND projectID='$eid'";
            
    $result = @mysql_query($query) or die(mysql_error()); 
    now the problem is that when i click the submit button, an error occured
    Notice: Undefined index: eid in c:\inetpub\wwwroot\project\projectedit.php on line 9
    line 9 is the code above,in the edit page -->$eid = $_GET['eid'];

    my impression with this is that if the index eid is undefined, by the time i click the edit, it will prompt me that eid is undefined, but in this case, it validates the value of eid then the edit page loads....unfortunately, by the time i click the submit/update button, the quoted error above appears...

    hope someone can point me where to modify the code...

    thanks in advance.

  2. #2
    dooby dooby doo silver trophybronze trophy
    spikeZ's Avatar
    Join Date
    Aug 2004
    Location
    Manchester UK
    Posts
    13,806
    Mentioned
    158 Post(s)
    Tagged
    3 Thread(s)
    The eid is being passed to the page before the form is submitted, therefore when the form is submitted it is reloading the page and not passing the eid inthe url.

    What you could do is put a hidden field in the form with the eid in it or append the url from the submit form.

    OR
    it might be easier to register the $_GET['eid'] as a session variable as you have done with the id....

    Mike
    Mike Swiffin - Community Team Advisor
    Only a woman can read between the lines of a one word answer.....

  3. #3
    SitePoint Enthusiast
    Join Date
    Dec 2002
    Location
    Dubai - UAE
    Posts
    77
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    then in my edit page

    PHP Code:
    $id = $_SESSION['userID'];

    $eid = $_GET['eid'];

    if (isset(
    $_POST['submit']))
    {
    ...
    some codes here...
    }
    I'm bit confused why you are using $_POST['submit'] as you are passing eid as query string.

    If you are passing eid as query string, then you need to check if query string array is not empty and eid index is set. i.e.
    Code:
    $id = $_SESSION['userID']; 
    if (!empty($_GET) && isset($_GET['eid'])) 
    { 
    $eid = $_GET['eid'];
    ...some codes here... 
    }
    Hope it helps

  4. #4
    dooby dooby doo silver trophybronze trophy
    spikeZ's Avatar
    Join Date
    Aug 2004
    Location
    Manchester UK
    Posts
    13,806
    Mentioned
    158 Post(s)
    Tagged
    3 Thread(s)
    gul, he's not passing it from the form, that's the problem. The original eid is coming from the url from the previous page.
    Mike Swiffin - Community Team Advisor
    Only a woman can read between the lines of a one word answer.....

  5. #5
    SitePoint Enthusiast
    Join Date
    Dec 2002
    Location
    Dubai - UAE
    Posts
    77
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If he is posting the data through form, then he need to store eid in some hidden field first and then collect on edit page from $_POST array. Your suggestion is right if that is the case but I'm not in favor of storing eid in session array

  6. #6
    SitePoint Zealot
    Join Date
    Feb 2005
    Posts
    109
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by spikeZ

    What you could do is put a hidden field in the form with the eid in it or append the url from the submit form.
    how can i do this?can you do me a sample??
    thanks guys..

  7. #7
    dooby dooby doo silver trophybronze trophy
    spikeZ's Avatar
    Join Date
    Aug 2004
    Location
    Manchester UK
    Posts
    13,806
    Mentioned
    158 Post(s)
    Tagged
    3 Thread(s)
    Sure, here you go....
    PHP Code:
    <? 
    # use if(isset(.... to avoid any undefined errors
    if(isset($_GET['eid'])) {
    $eid=$_GET['eid'];
    }

    if(isset(
    $_POST['submit'])) {
        echo 
    $_POST['element1'] . '<br>';
        echo 
    $_POST['get_eid'] . '<br>';
    }
    ?>
    <html>
    <head>
    <title>Untitled Document</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    </head>

    <body>
    <a href="?eid=2">test eid</a>
    <form name="textform" action="<?php $_SERVER['PHP_SELF']; ?>" method="post">
    <input type="text" name="element1"><br>
    <input type="hidden" name="get_eid" value="<?php echo $eid?>"><br>
    <input type="submit" name="submit">
    </form>
    </body>
    </html>
    The eid is defined before the form is sent and captured in a hidden form element.

    Cheers

    SpikeZ
    Mike Swiffin - Community Team Advisor
    Only a woman can read between the lines of a one word answer.....

  8. #8
    SitePoint Zealot
    Join Date
    Feb 2005
    Posts
    109
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks spikez...i was just wonderin why this problem occur...the fact that the edit page loaded, it means that the first eid was defined,right?what really bugs me is that, by the time i click the submit button, then the eid is undefined...the action of my form is <?php $_SERVER['PHP_SELF']; ?> , that means, the same page will load, but blank.....correct me if i'm wrong and your opinion is very much appreciated....thanks again...

  9. #9
    SitePoint Zealot
    Join Date
    Feb 2005
    Posts
    109
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hi...did what you advised...but the value of eid was printed in the handling SELF page...right after the same error that indicates the eid is undefined...

  10. #10
    dooby dooby doo silver trophybronze trophy
    spikeZ's Avatar
    Join Date
    Aug 2004
    Location
    Manchester UK
    Posts
    13,806
    Mentioned
    158 Post(s)
    Tagged
    3 Thread(s)
    can you post your page code?
    Mike Swiffin - Community Team Advisor
    Only a woman can read between the lines of a one word answer.....

  11. #11
    SitePoint Zealot
    Join Date
    Feb 2005
    Posts
    109
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    this is the edit page code where the problem is
    PHP Code:
    <?
    $id 
    $_SESSION['userID'];
    $eid $_GET['eid'];

    if (isset(
    $_POST['submit']))
    {
        
    $message NULL;
        
        
    //check for project title
        
    if (empty($_POST['projecttitle']))
        {
            
    $pt false;
            
    $message .= 'You forgot to enter the project title<br>';
        }
        else
        {
            
    $pt $_POST['projecttitle'];
        }
        
        
    //check for company's role
        
    if ($_POST['companyrole'] == '')
        {
            
    $r false;
            
    $message .= 'Please select at least one role<br>';
        }
        else
        {        
            
    $r $_POST['companyrole'];
        }
        
        
    //check for location
        
    if (empty($_POST['location']))
        {
            
    $l false;
            
    $message .= 'You forgot to enter the location<br>';
        }
        else
        {
            
    $l $_POST['location'];
        }
        
        
    //check for description
        
    if (empty($_POST['description']))
        {
            
    $d false;
            
    $message .= 'You forgot to enter the project description<br>';
        }
        else
        {
            
    $d $_POST['description'];
        }
        
        
    //check for objective
        
    if (empty($_POST['objective']))
        {
            
    $o false;
            
    $message .= 'You forgot to enter the project objective<br>';
        }
        else
        {
            
    $o $_POST['objective'];
        }
        
        
    //check for justification
        
    if (empty($_POST['justification']))
        {
            
    $j false;
            
    $message .= 'You forgot to enter the project justification<br>';
        }
        else
        {
            
    $j $_POST['justification'];
        }
        
        
    //check for project duration start date
        
    if (empty($_POST['startmonth']) || empty($_POST['startday']) || empty($_POST['startyear']))
        {
            
    $sd false;
            
    $message .= 'You forgot to enter the project start date<br>';
        }
        else
        {
            
    $sd $_POST['startyear']."-".$_POST['startmonth']."-".$_POST['startday'];
        }
        
        
    //check for poject duration end date
        
    if (empty($_POST['endmonth']) || empty($_POST['endday']) || empty($_POST['endyear']))
        {
            
    $ed false;
            
    $message .= 'You forgot to enter the project end date<br>';
        }
        else
        {
            
    $ed $_POST['endyear']."-".$_POST['endmonth']."-".$_POST['endday'];
        }
        
        
    //check for implementing organizations - lead firm
        
    if (empty($_POST['leadfirm']))
        {
            
    $lf false;
            
    $message .= 'You forgot to enter the project lead firm<br>';
        }
        else
        {
            
    $lf $_POST['leadfirm'];
        }
        
        
    //check for implementing organizations - co-sponsoring firm    
        
    if (isset($_POST['cosponsoringfirm']))
        {
            
    $csf $_POST['cosponsoringfirm'];
        }
        
        
    //check for delegated department
        
    if ($_POST['delegateddepartment'] == '')
        {
            
    $dd false;
            
    $message .= 'Please select at least one department<br>';
        }
        else
        {
            
    $dd $_POST['delegateddepartment'];
        }
        
        
    //check for assigned person
        
    if ($_POST['assignedperson'] == '')
        {
            
    $ap false;
            
    $message .= 'Please select at least one assigned person<br>';
        }
        else
        {
            
    $ap $_POST['assignedperson'];
        }
        
        
    //check for type of organization
        
    if (empty($_POST['type']))
        {
            
    $t false;
            
    $message .= 'You forgot to enter the type of organization<br>';
        }
        else
        {
            
    $t $_POST['type'];
        }
        
        
    //check for category of organization
        
    if ($_POST['category'] == '')
        {
            
    $c false;
            
    $message .= 'Please select at least one category<br>';
        }
        else
        {        
            
    $c $_POST['category'];
        }
        
        
    //check for contact person
        
    if (empty($_POST['contactperson']))
        {
            
    $cp false;
            
    $message .= 'You forgot to enter the project contact persons<br>';
        }
        else
        {
            
    $cp $_POST['contactperson'];
        }
        
        
    //check for expected results
        
    if (empty($_POST['expectedresult']))
        {
            
    $er false;
            
    $message .= 'You forgot to enter the project expected result<br>';
        }
        else
        {
            
    $er $_POST['expectedresult'];
        }
        
        if (
    $pt && $r && $l && $d && $o && $j && $sd && $ed && $lf && $csf && $dd && $ap && $t && $c && $cp && $er)
        {    
            
    $query "UPDATE projects SET projecttitle='$pt', companyrole='$r', location='$l', description='$d', 
            objective='
    $o', justification='$j', startdate='$sd', enddate='$ed', leadfirm='$lf', cosponsoringfirm='$csf', 
            delegateddepartment='
    $dd', assignedperson='$ap', type='$t', category='$c', contactperson='$cp', 
            expectedresult='
    $er', userID='$id', postupdate=NOW() WHERE userID='$id' AND projectID='$eid'";
            
    $result = @mysql_query($query) or die(mysql_error());
                                                            
            if (
    $result)
            {                            
                echo 
    '<b>Your project profile has been updated</b>';
                echo 
    '<meta http-equiv="refresh" content="3;url=http://localhost/project/project.php">';
                exit();
            }
            else
            {
                
    $message .= 'Your project cannot be updated due to system error<br>'.mysql_error();
            }
            
    mysql_close();
        }
        else
        {
            
    $message .= 'Please try again<br>';
        }
    }
    //end of submit

    //pulldown menu
    $query "SELECT userID, concat(firstname,' ',lastname) as fullname FROM profile ORDER BY fullname ASC";
    $result = @mysql_query($query);
    $pulldown "<option value=''> - Delegate A Person - </option>";

    while (
    $row mysql_fetch_array($resultMYSQL_ASSOC))
    {
        
    $pulldown .= strtoupper("<option value=\"{$row['fullname']}\">{$row['fullname']}</option><br>");
    }

    if (isset(
    $message))
    {
        echo 
    '<font color=red>'.$message.'</font>';
    }

    //edit query
    $query "SELECT projecttitle, companyrole, p.location, p.description, objective, 
    justification, DATE_FORMAT(startdate, '%M %e, %Y'),
     DATE_FORMAT(enddate, '%M %e, %Y'), designateddepartment, assignedperson, leadfirm, 
     cosponsoringfirm, type, category, contactperson, expectedresult, firstname FROM projects AS p, 
     profile AS pr WHERE projectID = '"
    .$eid."'";
    $result mysql_query($query) or die(mysql_error());
    $row mysql_fetch_assoc($result) or die(mysql_error());
    ?>

    <form action="<? echo $_SERVER['PHP_SELF']; ?>" method="post" >
    <table width="100%" border="0" bgcolor="#EDEFE1" cellpadding="0" cellspacing="0" align="center">
    <tr>
    <td>
    <table width="100%" border="1" cellpadding="0" cellspacing="0" class="maintableborder">
      <tr>
        <td>

    <table width="100%" border="0" cellpadding="0" cellspacing="0" class="tablehead">
      <tr>
        <td align="center"><font color="#ffffff" size="+1">Create New Project</font></td>
      </tr>
    </table>
    <table width="100%" >
      <tr valign="top">
        <td width="50%">
            <table width="100%" cellpadding="1" cellspacing="1" border="0">
                <tr valign="top">
                    <td width="30%"><b/>Project Title</td>
                    <td width="70%">
                    <input name="projecttitle" type="text" size="31" value="<? echo $row['projecttitle']; ?>">
                    </td>
                </tr>
                <tr valign="top">
                    <td width="30%"><b/>Company's Role</td>
                          <td width="70%">
                        <select name='companyrole'>
                        <option><? echo $row['companyrole']; ?></option>
                        <option value=''> - Select Company's Role - </option>
                        <option value='Contractor'>Contractor</option>
                        <option value='Sub-Contractor'>Sub-Contractor</option>
                        <option value='Outscoring'>Outscoring</option>
                        </select>
                        </td>
                </tr>
                <tr valign="top">
                    <td width="30%"><b/>Location</td>
                    <td width="70%">
                    <input name="location" type="text" size="31" value="<? echo $row['location']; ?>">
                    </td>
                </tr>
                <tr valign="top">
                    <td width="30%"><b/>Description</td>
                    <td width="70%">
                    <textarea name="description" cols="30" rows="5"><? echo $row['description']; ?></textarea>
                    </td>
                </tr>
                <tr valign="top">
                    <td width="30%"><b/>Objectives</td>
                    <td width="70%">
                    <textarea name="objective" cols="30" rows="5"><? echo $row['objective']; ?></textarea>
                    </td>
                </tr>
                <tr valign="top">
                    <td width="30%"><b/>Justifications</td>
                    <td width="70%">
                    <textarea name="justification" cols="30" rows="5"><? echo $row['justification']; ?></textarea>
                    </td>
                </tr>
                <tr valign="top">
                    <td width="30%"><b/>Project Duration                    
                    </td>
                    <td width="70%">
                        <table width="100%" cellpadding="1" cellspacing="1">
                            <tr>
                                <td width="20%"><b/>Start Date</td>
                                <td width="80%"><? calendar1(); ?></td>
                            </tr>
                            <tr>
                                <td width="20%"><b/>End Date</td>
                                <td width="80%"><? calendar2(); ?></td>
                            </tr>                    
                        </table>
                    </td>
                </tr>
            </table>
        </td>
        <td width="50%">
            <table width="100%" cellpadding="1" cellspacing="1">
                <tr valign="top">
                    <td width="30%"><b/>Delegated Department</td>
                          <td width="70%">
                        <select name='delegateddepartment'>
                        <option><? echo $row['designateddepartment']; ?></option>
                        <option value=''> - Select A Department - </option>
                        <option value='CBDC'>CBDC</option>
                        <option value='JCI'>JCI</option>                    
                        <option value='JIPI'>JIPI</option>
                        <option value='JISI'>JISI</option>
                        <option value='JMFI'>JMFI</option>
                        <option value='JCDI'>JCDI</option>
                        <option value='MBC'>MBC</option>
                        <option value='MFI'>MFI</option>                    
                        </select>
                        </td>
                </tr>            
                <tr valign="top">
                      <td width="40%"><b/>Assigned Person</td>
                    <td width="60%">
                        <select name="assignedperson">
                        <option><? echo $row['assignedperson']; ?></option>
                            <? echo $pulldown?>
                        </select>
                    </td>
                </tr>
                <tr valign="top">
                    <td width="40%"><b/>Implementing Organization(s)                    
                    </td>
                    <td width="60%">
                        <table width="100%" cellpadding="1" cellspacing="1">
                            <tr>
                                <td width="20%"><b/>Lead Firm</td>
                                <td width="80%">
                                <input name="leadfirm" type="text" size="20" value="<? echo $row['leadfirm']; ?>">
                                </td>
                            </tr>
                            <tr>
                                <td width="20%"><b/>Co-Sponsoring Firm</td>
                                <td width="80%">
                                <input name="cosponsoringfirm" type="text" size="20" value="<? echo $row['cosponsoringfirm']; ?>">
                                </td>
                            </tr>                    
                        </table>
                    </td>
                </tr>
                <tr valign="top">
                      <td width="40%"><b/>Type of Organization(s)</td>
                    <td width="60%">
                    <input name="type" type="text" size="31" value="<? echo $row['type']; ?>">
                    </td>
                </tr>
                <tr valign="top">
                    <td width="40%"><b/>Category of Organization(s)</td>
                    <td width="60%">
                        <select name="category">
                        <option><? echo $row['category']; ?></option>
                        <option value=''> - Select Category of Organizations - </option>
                        <option value='Business and Industry'>Business and Industry</option>
                        <option value='Research and Academic'>Research and Academic</option>
                        <option value='NGOs or Foundations'>NGOs or Foundations</option>
                        <option value='Gov't Departments or Agencies'>Gov't Departments or Agencies</option>
                        </select>
                    </td>
                </tr>
                <tr valign="top">
                    <td width="40%"><b/>Contact Persons</td>
                    <td width="60%">
                    <input name="contactperson" type="text" size="31" value="<? echo $row['contactperson']; ?>">
                    </td>
                </tr>
                <tr valign="top">
                    <td width="40%"><b/>Expected Results</td>
                    <td width="60%">
                    <input name="expectedresult" type="text" size="31" value="<? echo $row['expectedresult']; ?>">
                    
                    </td>
                </tr>
                <tr valign="top">
                    <td width="40%"></td>
                    <td width="60%">
                    <input type="submit" name="submit" value="update" class="buttonformat" />
                    </td>
                </tr>
            </table>
        </td>
      </tr>
    </table>
    </td>
      </tr>
    </table>
    </td>
    </tr>
    </table>
    </form>
    here's the view page that is to be edited by the above page
    PHP Code:
    <?            
    $id 
    $_GET['pid'];
    $fn $_SESSION['firstname'];
    $uid $_SESSION['userID'];        
                
    $query "SELECT projecttitle, companyrole, p.location, p.description, objective, 
    justification, DATE_FORMAT(startdate, '%M %e, %Y'),
     DATE_FORMAT(enddate, '%M %e, %Y'), designateddepartment, assignedperson, 
     leadfirm, cosponsoringfirm, type, category, contactperson, expectedresult, firstname 
     FROM projects AS p, profile AS pr
    WHERE p.userID = pr.userID AND projectID='
    $id'";
    $result = @mysql_query($query);
            
    if (
    $result)
    {
        
    $row mysql_fetch_array($resultMYSQL_NUM);
        
        
    //report edit
        
    $editquery "SELECT userID, projectID FROM projects WHERE userID='$uid' AND projectID='$id'";
        
    $editresult = @mysql_query($editquery) or die(mysql_error());
        if (
    mysql_fetch_assoc($editresult))
        {
            
    $edit '<a href="projectedit.php?eid='.$id.'" class=under>EDIT</a>';
        }
        else
           {
         
    $edit '&nbsp;';
        }
        
        echo 
    "
        <table width=100% border=1 cellpadding=0 cellspacing=0 class=maintableborder><tr><td>
            <table width=100% border=0 cellpadding=0 cellspacing=0 class=tablehead>
                  <tr>
                    <td align=center><font color=#ffffff size=+1>Project Profile</font></td>
                  </tr>
            </table>
        
            <table width=100% border=0 cellpadding=1 cellspacing=0 bgcolor=#EDEFE1>  
                  <tr valign=top>
                    <td width=20% class=tableborder><b/>Project Title</td>
                    <td width=80% class=tableborder>"
    .ucwords($row[0])."</td>
                  </tr>
                  <tr valign=top>
                    <td width=20% class=tableborder><b/>Company's Role</td>
                    <td width=80% class=tableborder>"
    .nl2br($row[1])."</td>
                  </tr>
                  <tr valign=top>
                    <td width=20% class=tableborder><b/>Location</td>
                    <td width=80% class=tableborder>"
    .ucwords($row[2])."</td>
                  </tr>
                  <tr valign=top>
                    <td width=20% class=tableborder><b/>Description</td>
                    <td width=80% class=tableborder>"
    .nl2br($row[3])."</td>
                  </tr>
                  <tr valign=top>
                    <td width=20% class=tableborder><b/>Objectives</td>
                    <td width=80% class=tableborder>"
    .nl2br($row[4])."</td>
                  </tr>
                  <tr valign=top>
                    <td width=20% class=tableborder><b/>Justification</td>
                    <td width=80% class=tableborder>"
    .nl2br($row[5])."</td>
                  </tr>
                  <tr valign=top>
                    <td width=20% class=tableborder><b/>Project Duration</td>
                    <td width=80% class=tableborder>
                        <table width=100% border=0 cellpadding=0 cellspacing=0>
                              <tr>
                                <td width=15%><b/>Start Date</td>
                                <td width=85%>"
    .nl2br($row[6])."</td>
                              </tr>
                              <tr>
                                <td width=15%><b/>End Date</td>
                                <td width=85%>"
    .nl2br($row[7])."</td>
                              </tr>
                        </table>
                    </td>
                  </tr>
                  <tr valign=top>
                    <td width=20% class=tableborder><b/>Designated Person</td>
                    <td width=80% class=tableborder>"
    .strtoupper($row[8])."</td>
                  </tr>
                  <tr valign=top>
                    <td width=20% class=tableborder><b/>Assigned Person</td>
                    <td width=80% class=tableborder>"
    .ucwords($row[9])."</td>
                  </tr>
                  <tr valign=top>
                    <td width=20% class=tableborder><b/>Implementeing Organization(s)</td>
                    <td width=80% class=tableborder>
                        <table width=100% border=0 cellpadding=0 cellspacing=0>
                              <tr>
                                <td width=15%><b/>Lead Firm</td>
                                <td width=85%>"
    .ucwords($row[10])."</td>
                              </tr>
                              <tr>
                                <td width=15%><b/>Co-Sponsoring Firm</td>
                                <td width=85%>"
    .ucwords($row[11])."</td>
                              </tr>
                        </table>
                    </td>
                  </tr>
                  <tr valign=top>
                    <td width=20% class=tableborder><b/>Type of Organization(s)</td>
                    <td width=80% class=tableborder>"
    .ucwords($row[12])."</td>
                  </tr>
                  <tr valign=top>
                       <td width=20% class=tableborder><b/>Category of Organization(s)</td>
                    <td width=80% class=tableborder>"
    .nl2br($row[13])."</td>
                  </tr>
                  <tr valign=top>
                    <td width=20% class=tableborder><b/>Contact Persons</td>
                    <td width=80% class=tableborder>"
    .nl2br($row[14])."</td>
                  </tr>
                  <tr valign=top>
                    <td width=20% class=tableborder><b/>Expected Results</td>
                    <td width=80% class=tableborder>"
    .nl2br($row[15])."</td>
                  </tr>
                  <tr valign=top>
                    <td width=20% class=tableborder>&nbsp;</td>
                    <td width=80% class=tableborder>&nbsp;</td>
                  </tr>
                  <tr valign=top>
                    <td width=20% class=tableborder>
    $edit</td>
                    <td width=80% class=tableborder>&nbsp;</td>
                  </tr>
      
            </table>
        </td></tr></table>
        "
    ;
    }
    else
    {
        echo 
    'system error!<br>'.mysql_error();
    }
    ?>
    note: the value of pid of my viewpage code(the second code above) is from another page..thanks..

  12. #12
    dooby dooby doo silver trophybronze trophy
    spikeZ's Avatar
    Join Date
    Aug 2004
    Location
    Manchester UK
    Posts
    13,806
    Mentioned
    158 Post(s)
    Tagged
    3 Thread(s)
    I think the problem is $_GET['eid'] is called from the previous page and when the form is submitted it tries to call it again.
    Simple fix....
    PHP Code:
    if(isset($_GET['eid'])) {
    $eid $_GET['eid']; 

    I hope!

    Mike
    Mike Swiffin - Community Team Advisor
    Only a woman can read between the lines of a one word answer.....

  13. #13
    SitePoint Zealot
    Join Date
    Feb 2005
    Posts
    109
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i did that...but the problem is that line 193 still saying undefined variable. line 193 is is the last line in the code below...refering to the projectID
    PHP Code:
    $query "UPDATE projects SET projecttitle='$pt', companyrole='$r', location='$l', description='$d',
            objective='
    $o', justification='$j', startdate='$sd', enddate='$ed', leadfirm='$lf', cosponsoringfirm='$csf',
            delegateddepartment='
    $dd', assignedperson='$ap', type='$t', category='$c', contactperson='$cp',
            expectedresult='
    $er', userID='$id', postupdate=NOW() WHERE userID='$id' AND projectID='$eid'"
    since it is undefined, it is automatically opens the view page and there are no changes to fields that i updated...

  14. #14
    dooby dooby doo silver trophybronze trophy
    spikeZ's Avatar
    Join Date
    Aug 2004
    Location
    Manchester UK
    Posts
    13,806
    Mentioned
    158 Post(s)
    Tagged
    3 Thread(s)
    don't forget to redifne $edi as $_POST['eid'] after the form is submitted...
    Mike Swiffin - Community Team Advisor
    Only a woman can read between the lines of a one word answer.....

  15. #15
    SitePoint Zealot
    Join Date
    Feb 2005
    Posts
    109
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i hope your having much patience with me......bu how can i do it??

  16. #16
    dooby dooby doo silver trophybronze trophy
    spikeZ's Avatar
    Join Date
    Aug 2004
    Location
    Manchester UK
    Posts
    13,806
    Mentioned
    158 Post(s)
    Tagged
    3 Thread(s)
    simply
    PHP Code:
    if (isset($_POST['submit'])) 

        
    $message NULL
    $eid $_POST['eid']; 
    See what happens!
    BTW, I'm married so I have to have lots of patience!

    Mike
    Mike Swiffin - Community Team Advisor
    Only a woman can read between the lines of a one word answer.....

  17. #17
    SitePoint Zealot
    Join Date
    Feb 2005
    Posts
    109
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hehe...thanks for the patience..

    this code generated and error...still undefined index eid
    $eid = $_POST['eid'];

  18. #18
    dooby dooby doo silver trophybronze trophy
    spikeZ's Avatar
    Join Date
    Aug 2004
    Location
    Manchester UK
    Posts
    13,806
    Mentioned
    158 Post(s)
    Tagged
    3 Thread(s)
    look at the name of your hidden form element......
    PHP Code:
    $eid $_POST['get_eid']; 
    Mike Swiffin - Community Team Advisor
    Only a woman can read between the lines of a one word answer.....

  19. #19
    SitePoint Zealot
    Join Date
    Feb 2005
    Posts
    109
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    yup...i mean...i edited my previous code and disregarded the hidden form because the value of the eid is appearing...,.

  20. #20
    SitePoint Zealot
    Join Date
    Feb 2005
    Posts
    109
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i have disregarded that form element...but still,the problem exists...

  21. #21
    dooby dooby doo silver trophybronze trophy
    spikeZ's Avatar
    Join Date
    Aug 2004
    Location
    Manchester UK
    Posts
    13,806
    Mentioned
    158 Post(s)
    Tagged
    3 Thread(s)
    PHP Code:
    <? 
    $id 
    $_SESSION['userID']; 
    if(isset(
    $_GET['eid'])) {
    $eid $_GET['eid']; 
    }

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

        
    $message NULL
         
    $eid $_POST['get_eid'];
        
    //check for project title 
        
    if (empty($_POST['projecttitle'])) 
        { 
            
    $pt false
            
    $message .= 'You forgot to enter the project title<br>'
        } 
        else 
        { 
            
    $pt $_POST['projecttitle']; 
        } 
         
        
    //check for company's role 
        
    if ($_POST['companyrole'] == ''
        { 
            
    $r false
            
    $message .= 'Please select at least one role<br>'
        } 
        else 
        {         
            
    $r $_POST['companyrole']; 
        } 
         
        
    //check for location 
        
    if (empty($_POST['location'])) 
        { 
            
    $l false
            
    $message .= 'You forgot to enter the location<br>'
        } 
        else 
        { 
            
    $l $_POST['location']; 
        } 
         
        
    //check for description 
        
    if (empty($_POST['description'])) 
        { 
            
    $d false
            
    $message .= 'You forgot to enter the project description<br>'
        } 
        else 
        { 
            
    $d $_POST['description']; 
        } 
         
        
    //check for objective 
        
    if (empty($_POST['objective'])) 
        { 
            
    $o false
            
    $message .= 'You forgot to enter the project objective<br>'
        } 
        else 
        { 
            
    $o $_POST['objective']; 
        } 
         
        
    //check for justification 
        
    if (empty($_POST['justification'])) 
        { 
            
    $j false
            
    $message .= 'You forgot to enter the project justification<br>'
        } 
        else 
        { 
            
    $j $_POST['justification']; 
        } 
         
        
    //check for project duration start date 
        
    if (empty($_POST['startmonth']) || empty($_POST['startday']) || empty($_POST['startyear'])) 
        { 
            
    $sd false
            
    $message .= 'You forgot to enter the project start date<br>'
        } 
        else 
        { 
            
    $sd $_POST['startyear']."-".$_POST['startmonth']."-".$_POST['startday']; 
        } 
         
        
    //check for poject duration end date 
        
    if (empty($_POST['endmonth']) || empty($_POST['endday']) || empty($_POST['endyear'])) 
        { 
            
    $ed false
            
    $message .= 'You forgot to enter the project end date<br>'
        } 
        else 
        { 
            
    $ed $_POST['endyear']."-".$_POST['endmonth']."-".$_POST['endday']; 
        } 
         
        
    //check for implementing organizations - lead firm 
        
    if (empty($_POST['leadfirm'])) 
        { 
            
    $lf false
            
    $message .= 'You forgot to enter the project lead firm<br>'
        } 
        else 
        { 
            
    $lf $_POST['leadfirm']; 
        } 
         
        
    //check for implementing organizations - co-sponsoring firm     
        
    if (isset($_POST['cosponsoringfirm'])) 
        { 
            
    $csf $_POST['cosponsoringfirm']; 
        } 
         
        
    //check for delegated department 
        
    if ($_POST['delegateddepartment'] == ''
        { 
            
    $dd false
            
    $message .= 'Please select at least one department<br>'
        } 
        else 
        { 
            
    $dd $_POST['delegateddepartment']; 
        } 
         
        
    //check for assigned person 
        
    if ($_POST['assignedperson'] == ''
        { 
            
    $ap false
            
    $message .= 'Please select at least one assigned person<br>'
        } 
        else 
        { 
            
    $ap $_POST['assignedperson']; 
        } 
         
        
    //check for type of organization 
        
    if (empty($_POST['type'])) 
        { 
            
    $t false
            
    $message .= 'You forgot to enter the type of organization<br>'
        } 
        else 
        { 
            
    $t $_POST['type']; 
        } 
         
        
    //check for category of organization 
        
    if ($_POST['category'] == ''
        { 
            
    $c false
            
    $message .= 'Please select at least one category<br>'
        } 
        else 
        {         
            
    $c $_POST['category']; 
        } 
         
        
    //check for contact person 
        
    if (empty($_POST['contactperson'])) 
        { 
            
    $cp false
            
    $message .= 'You forgot to enter the project contact persons<br>'
        } 
        else 
        { 
            
    $cp $_POST['contactperson']; 
        } 
         
        
    //check for expected results 
        
    if (empty($_POST['expectedresult'])) 
        { 
            
    $er false
            
    $message .= 'You forgot to enter the project expected result<br>'
        } 
        else 
        { 
            
    $er $_POST['expectedresult']; 
        } 
         
        if (
    $pt && $r && $l && $d && $o && $j && $sd && $ed && $lf && $csf && $dd && $ap && $t && $c && $cp && $er
        {     
            
    $query "UPDATE projects SET projecttitle='$pt', companyrole='$r', location='$l', description='$d', 
            objective='
    $o', justification='$j', startdate='$sd', enddate='$ed', leadfirm='$lf', cosponsoringfirm='$csf', 
            delegateddepartment='
    $dd', assignedperson='$ap', type='$t', category='$c', contactperson='$cp', 
            expectedresult='
    $er', userID='$id', postupdate=NOW() WHERE userID='$id' AND projectID='$eid'"
            
    $result = @mysql_query($query) or die(mysql_error()); 
                                                             
            if (
    $result
            {                             
                echo 
    '<b>Your project profile has been updated</b>'
                echo 
    '<meta http-equiv="refresh" content="3;url=http://localhost/project/project.php">'
                exit(); 
            } 
            else 
            { 
                
    $message .= 'Your project cannot be updated due to system error<br>'.mysql_error(); 
            } 
            
    mysql_close(); 
        } 
        else 
        { 
            
    $message .= 'Please try again<br>'
        } 
    }
    //end of submit 

    //pulldown menu 
    $query "SELECT userID, concat(firstname,' ',lastname) as fullname FROM profile ORDER BY fullname ASC"
    $result = @mysql_query($query); 
    $pulldown "<option value=''> - Delegate A Person - </option>"

    while (
    $row mysql_fetch_array($resultMYSQL_ASSOC)) 

        
    $pulldown .= strtoupper("<option value=\"{$row['fullname']}\">{$row['fullname']}</option><br>"); 


    if (isset(
    $message)) 

        echo 
    '<font color=red>'.$message.'</font>'


    //edit query 
    $query "SELECT projecttitle, companyrole, p.location, p.description, objective, 
    justification, DATE_FORMAT(startdate, '%M %e, %Y'), 
    DATE_FORMAT(enddate, '%M %e, %Y'), designateddepartment, assignedperson, leadfirm, 
    cosponsoringfirm, type, category, contactperson, expectedresult, firstname FROM projects AS p, 
    profile AS pr WHERE projectID = '"
    .$eid."'"
    $result mysql_query($query) or die(mysql_error()); 
    $row mysql_fetch_assoc($result) or die(mysql_error()); 
    ?> 

    <form action="<? echo $_SERVER['PHP_SELF']; ?>" method="post" > 
    <table width="100%" border="0" bgcolor="#EDEFE1" cellpadding="0" cellspacing="0" align="center"> 
    <tr> 
    <td> 
    <table width="100%" border="1" cellpadding="0" cellspacing="0" class="maintableborder"> 
      <tr> 
        <td> 

    <table width="100%" border="0" cellpadding="0" cellspacing="0" class="tablehead"> 
      <tr> 
        <td align="center"><font color="#ffffff" size="+1">Create New Project</font></td> 
      </tr> 
    </table> 
    <table width="100%" > 
      <tr valign="top"> 
        <td width="50%"> 
            <table width="100%" cellpadding="1" cellspacing="1" border="0"> 
                <tr valign="top"> 
                    <td width="30%"><b/>Project Title</td> 
                    <td width="70%"> 
                    <input name="projecttitle" type="text" size="31" value="<? echo $row['projecttitle']; ?>"> 
                    </td> 
                </tr> 
                <tr valign="top"> 
                    <td width="30%"><b/>Company's Role</td> 
                          <td width="70%"> 
                        <select name='companyrole'> 
                        <option><? echo $row['companyrole']; ?></option> 
                        <option value=''> - Select Company's Role - </option> 
                        <option value='Contractor'>Contractor</option> 
                        <option value='Sub-Contractor'>Sub-Contractor</option> 
                        <option value='Outscoring'>Outscoring</option> 
                        </select> 
                        </td> 
                </tr> 
                <tr valign="top"> 
                    <td width="30%"><b/>Location</td> 
                    <td width="70%"> 
                    <input name="location" type="text" size="31" value="<? echo $row['location']; ?>"> 
                    </td> 
                </tr> 
                <tr valign="top"> 
                    <td width="30%"><b/>Description</td> 
                    <td width="70%"> 
                    <textarea name="description" cols="30" rows="5"><? echo $row['description']; ?></textarea> 
                    </td> 
                </tr> 
                <tr valign="top"> 
                    <td width="30%"><b/>Objectives</td> 
                    <td width="70%"> 
                    <textarea name="objective" cols="30" rows="5"><? echo $row['objective']; ?></textarea> 
                    </td> 
                </tr> 
                <tr valign="top"> 
                    <td width="30%"><b/>Justifications</td> 
                    <td width="70%"> 
                    <textarea name="justification" cols="30" rows="5"><? echo $row['justification']; ?></textarea> 
                    </td> 
                </tr> 
                <tr valign="top"> 
                    <td width="30%"><b/>Project Duration                     
                    </td> 
                    <td width="70%"> 
                        <table width="100%" cellpadding="1" cellspacing="1"> 
                            <tr> 
                                <td width="20%"><b/>Start Date</td> 
                                <td width="80%"><? calendar1(); ?></td> 
                            </tr> 
                            <tr> 
                                <td width="20%"><b/>End Date</td> 
                                <td width="80%"><? calendar2(); ?></td> 
                            </tr>                     
                        </table> 
                    </td> 
                </tr> 
            </table> 
        </td> 
        <td width="50%"> 
            <table width="100%" cellpadding="1" cellspacing="1"> 
                <tr valign="top"> 
                    <td width="30%"><b/>Delegated Department</td> 
                          <td width="70%"> 
                        <select name='delegateddepartment'> 
                        <option><? echo $row['designateddepartment']; ?></option> 
                        <option value=''> - Select A Department - </option> 
                        <option value='CBDC'>CBDC</option> 
                        <option value='JCI'>JCI</option>                     
                        <option value='JIPI'>JIPI</option> 
                        <option value='JISI'>JISI</option> 
                        <option value='JMFI'>JMFI</option> 
                        <option value='JCDI'>JCDI</option> 
                        <option value='MBC'>MBC</option> 
                        <option value='MFI'>MFI</option>                     
                        </select> 
                        </td> 
                </tr>             
                <tr valign="top"> 
                      <td width="40%"><b/>Assigned Person</td> 
                    <td width="60%"> 
                        <select name="assignedperson"> 
                        <option><? echo $row['assignedperson']; ?></option> 
                            <? echo $pulldown?> 
                        </select> 
                    </td> 
                </tr> 
                <tr valign="top"> 
                    <td width="40%"><b/>Implementing Organization(s)                     
                    </td> 
                    <td width="60%"> 
                        <table width="100%" cellpadding="1" cellspacing="1"> 
                            <tr> 
                                <td width="20%"><b/>Lead Firm</td> 
                                <td width="80%"> 
                                <input name="leadfirm" type="text" size="20" value="<? echo $row['leadfirm']; ?>"> 
                                </td> 
                            </tr> 
                            <tr> 
                                <td width="20%"><b/>Co-Sponsoring Firm</td> 
                                <td width="80%"> 
                                <input name="cosponsoringfirm" type="text" size="20" value="<? echo $row['cosponsoringfirm']; ?>"> 
                                </td> 
                            </tr>                     
                        </table> 
                    </td> 
                </tr> 
                <tr valign="top"> 
                      <td width="40%"><b/>Type of Organization(s)</td> 
                    <td width="60%"> 
                    <input name="type" type="text" size="31" value="<? echo $row['type']; ?>"> 
                    </td> 
                </tr> 
                <tr valign="top"> 
                    <td width="40%"><b/>Category of Organization(s)</td> 
                    <td width="60%"> 
                        <select name="category"> 
                        <option><? echo $row['category']; ?></option> 
                        <option value=''> - Select Category of Organizations - </option> 
                        <option value='Business and Industry'>Business and Industry</option> 
                        <option value='Research and Academic'>Research and Academic</option> 
                        <option value='NGOs or Foundations'>NGOs or Foundations</option> 
                        <option value='Gov't Departments or Agencies'>Gov't Departments or Agencies</option> 
                        </select> 
                    </td> 
                </tr> 
                <tr valign="top"> 
                    <td width="40%"><b/>Contact Persons</td> 
                    <td width="60%"> 
                    <input name="contactperson" type="text" size="31" value="<? echo $row['contactperson']; ?>"> 
                    </td> 
                </tr> 
                <tr valign="top"> 
                    <td width="40%"><b/>Expected Results</td> 
                    <td width="60%"> 
                    <input name="expectedresult" type="text" size="31" value="<? echo $row['expectedresult']; ?>"> 
                     <input type="hidden" name="get_eid" value="<?php echo $eid?>">
                    </td> 
                </tr> 
                <tr valign="top"> 
                    <td width="40%"></td> 
                    <td width="60%"> 
                    <input type="submit" name="submit" value="update" class="buttonformat" /> 
                    </td> 
                </tr> 
            </table> 
        </td> 
      </tr> 
    </table> 
    </td> 
      </tr> 
    </table> 
    </td> 
    </tr> 
    </table> 
    </form>
    Mike Swiffin - Community Team Advisor
    Only a woman can read between the lines of a one word answer.....

  22. #22
    SitePoint Zealot
    Join Date
    Feb 2005
    Posts
    109
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    that's really great spikez....its working now....thanks a lot man...

  23. #23
    dooby dooby doo silver trophybronze trophy
    spikeZ's Avatar
    Join Date
    Aug 2004
    Location
    Manchester UK
    Posts
    13,806
    Mentioned
    158 Post(s)
    Tagged
    3 Thread(s)
    Thank god for that!!!!!!

    No problem, glad it's working now!

    -S
    Mike Swiffin - Community Team Advisor
    Only a woman can read between the lines of a one word answer.....

  24. #24
    SitePoint Zealot
    Join Date
    Feb 2005
    Posts
    109
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    don't wori man, i have more problems to come.....hehehe...just kiddin', i hope it's only some minor problems...oh and by the way...u got a cute daughter...thanks again..


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •