Ravens PHP Scripts: Forums
 

 

View next topic
View previous topic
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> Modules
Author Message
Donovan
Client



Joined: Oct 07, 2003
Posts: 735
Location: Ohio

PostPosted: Sat Sep 24, 2005 6:58 pm Reply with quote

This is different than "Sorry, such file doesnt exist".

Why?

Maybe if I knew this I wouldn't keep having this same issue with my MILPACS module.

My addsoldier.php keeps telling me "Sorry, that module file was not found." when I click on submit.

AFAIK I tell PHPNuke where everything is:

Code:
require_once("mainfile.php");

@include_once("header.php");
$module_name = basename(dirname(__FILE__));
include("modules/$module_name/admin/addsoldier.php");
global $module_name, $db, $prefix;


My form processing

Code:
<form name="addsoldier" action="modules.php?name=MILPACS" method="POST">


And when submit is clicked at the bottom of the page

Code:
<input type="hidden" name="op" value="addsoldier"/>


I have this located in my index.php:

Code:
case "addsoldier":

      @include_once("modules/MILPACS/admin/addsoldier.php");
      break;


But I still get the not found error.
 
View user's profile Send private message Visit poster's website ICQ Number
hitwalker
Sells PC To Pay For Divorce



Joined:
Posts: 5661

PostPosted: Sat Sep 24, 2005 7:05 pm Reply with quote

Maybe its because im sleepy but shouldnt you try..
Code:
<form name="addsoldier" action="modules/MILPACS" method="POST">
 
View user's profile Send private message
Raven
Site Admin/Owner



Joined: Aug 27, 2002
Posts: 17088

PostPosted: Sat Sep 24, 2005 8:46 pm Reply with quote

hitwalker wrote:
Maybe its because im sleepy but shouldnt you try..
Code:
<form name="addsoldier" action="modules/MILPACS" method="POST">
Absolutely not. All modules must be invoked through modules.php?name=??????
 
View user's profile Send private message
Raven







PostPosted: Sat Sep 24, 2005 8:52 pm Reply with quote

Donovan,

What version of nuke is this?
 
Donovan







PostPosted: Sat Sep 24, 2005 9:04 pm Reply with quote

7.3

My address window (URL) states:
[ Only registered users can see links on this board! Get registered or login! ]

If the following is true

Code:
action="modules.php?name=<? echo $module_name?>


then shouldn't it say
[ Only registered users can see links on this board! Get registered or login! ]
 
kguske
Site Admin



Joined: Jun 04, 2004
Posts: 6433

PostPosted: Sat Sep 24, 2005 9:20 pm Reply with quote

You might want to use a hidden field called file instead of op.

Sorry - didn't read your whole post carefully.

_________________
I search, therefore I exist...
nukeSEO - nukeFEED - nukePIE - nukeSPAM - nukeWYSIWYG
 
View user's profile Send private message
kguske







PostPosted: Sat Sep 24, 2005 9:26 pm Reply with quote

There is no module named admin. The name parameter should be MILPACS.
 
Donovan







PostPosted: Sat Sep 24, 2005 9:27 pm Reply with quote

Which means I would have to change my if statement?

Code:
if ($op == "addsoldier") {

      // Validations go here
      // If all validations passed, save and exit, otherwise, redisplay with errors      
      $rank_id = intval($_POST[$rank_id]);
      $unit_id = intval($_POST[$unit_id]);
      $weapon_id = intval($_POST[$weapon_id]);
      $bio = addslashes($_POST[$bio]);
      $name = $_POST['name'];
      $uniform = $_POST['uniform'];
      $flag = $_POST['flag'];
      $location = $_POST['location'];
      $status = $_POST['status'];
      $p_mos = $_POST['p_mos'];
      $reports = $_POST['reports'];
      $position = $_POST['position'];
      $enlistment_dt = $_POST['enlistment_dt'];      
      $icq = $_POST['icq'];
      
      //Insert the values into the correct database with the right fields

      $result = $db->sql_query ("INSERT INTO " . $prefix . "_milpacs_members (uniqueid, name, uniform, rank_id, flag, location, status, p_mos, unit_id,  reports, position, weapon_id, enlistment_dt, icq, bio)".
         "VALUES ('NULL','$name','$uniform', $rank_id, '$flag', '$location', '$status', '$p_mos', $unit_id, '$reports', '$position', $weapon_id, '$enlistment_dt', '$icq', '$bio')");
 
Donovan







PostPosted: Sat Sep 24, 2005 9:30 pm Reply with quote

Here is my whole page.



Code:
<?php

/************************************************************************/
/* MILPACS (Military Personell and Classification System)               */
/* Author::Donovan [3rd ID]                                    */
/* Copyright (c) 2005 by Steven Donovan AKA Donovan [3rd ID]         */
/* Email:: [ Only registered users can see links on this board! Get registered or login! ]
/* Homepage::http://www.3rd-infantry-division.net                  */
/*                                                      */
/* This program is free software; you can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 2 of the License.       */
/*                                                                      */
/* This program is distributed in the hope that it will be useful, but  */
/* WITHOUT ANY WARRANTY; without even the implied warranty of           */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU     */
/* General Public License for more details.                             */
/*                                                                      */
/* If you want a copy of the GNU General Public License write to the    */
/* Free Software Foundation, Inc.                              */
/* 59 Temple Place, Suite 330, Boston, MA 02111-1307               */
/* USA                                                                  */
/************************************************************************/
/*********************************************************/
/* Add Soldier to MILPACS                                */
/*********************************************************/
if (stristr($_SERVER['SCRIPT_NAME'], "addsoldier.php")) {
    Header("Location: ../../index.php");
    die();
}
if (!in_groups('1-10-23')) {
   // Not authorized
    echo "<META HTTP-EQUIV=\"refresh\" content=\".1;URL=modules.php?name=MILPACS&file=accessdenied\">";
   echo "<a href=\"modules.php?name=MILPACS&file=accessdenied\">";
}


//finds the server's root directory
$index = 0;
require_once("mainfile.php");
include_once("header.php");
$module_name = basename(dirname(__FILE__));
global $module_name, $db, $prefix;

OpenTable();
   if ($op == "addsoldier") {
      // Validations go here
      // If all validations passed, save and exit, otherwise, redisplay with errors      
      $rank_id = intval($_POST[$rank_id]);
      $unit_id = intval($_POST[$unit_id]);
      $weapon_id = intval($_POST[$weapon_id]);
      $bio = addslashes($_POST[$bio]);
      $name = $_POST['name'];
      $uniform = $_POST['uniform'];
      $flag = $_POST['flag'];
      $location = $_POST['location'];
      $status = $_POST['status'];
      $p_mos = $_POST['p_mos'];
      $reports = $_POST['reports'];
      $position = $_POST['position'];
      $enlistment_dt = $_POST['enlistment_dt'];      
      $icq = $_POST['icq'];
      
      //Insert the values into the correct database with the right fields

      $result = $db->sql_query ("INSERT INTO " . $prefix . "_milpacs_members (uniqueid, name, uniform, rank_id, flag, location, status, p_mos, unit_id,  reports, position, weapon_id, enlistment_dt, icq, bio)".
         "VALUES ('NULL','$name','$uniform', $rank_id, '$flag', '$location', '$status', '$p_mos', $unit_id, '$reports', '$position', $weapon_id, '$enlistment_dt', '$icq', '$bio')");

         if (!$result) {
    echo("<p>Error adding Soldier!" . mysql_error() . "</p>");
}
//   else {
//      $result = $db->sql_query($sql);
//      echo "<META HTTP-EQUIV=\"refresh\" content=\"0;URL=modules.php?name=MILPACS&file=roster\">";
//   }
}     
         
         $DOCUMENT_ROOT = $_SERVER['DOCUMENT_ROOT'];
// Load Uniform images (Rank, Flag)
   $urlofimages="$DOCUMENT_ROOT/modules/MILPACS/images/uniform/";
   $uniformselecthtml = "<select name=\"uniform\">";
   $uniformselecthtml .= "<option value=\"\">Select Uniform Image</option>";
   if ($handle=@opendir($urlofimages)) {
      while ($imgfile = readdir($handle)) {
         if ($imgfile != "." && $imgfile != ".." && $imgfile != "" && $imgfile != "index.html" && $imgfile != "WS_FTP.LOG" && $imgfile != "Thumbs.db") {
//          echo "$imgfile<br>";
            if ($imgfile==$uniform) {
               $uniformselecthtml .= "<option value =\"$imgfile\" selected>$imgfile</option>";
            } else {
               $uniformselecthtml .= "<option value =\"$imgfile\" >$imgfile</option>";
            }
         }
      }
      @closedir($handle);
   }
   $uniformselecthtml .= "</select></td>";
// Load Ranks
   $rankselecthtml = "<select name=\"rank_id\">";
   $rankselecthtml .= "<option value=\"\">Select Rank</option>";
    $result2 = $db->sql_query("SELECT * FROM " . $prefix . "_milpacs_ranks order by rank_id");
   while ($rankrow = $db->sql_fetchrow($result2)) {
      if ($rankrow[rank_id]==$rank_id) {
         $rankselecthtml .= "<option value =\"$rankrow[rank_id]\" selected>$rankrow[rankname]</option>";
      } else {
         $rankselecthtml .= "<option value =\"$rankrow[rank_id]\" >$rankrow[rankname]</option>";
      }
   }
   $rankselecthtml .= "</select></td>";
// Load Flag images
   $urlofimages="$DOCUMENT_ROOT/modules/MILPACS/images/flags/";
   $flagselecthtml = "<select name=\"flag\">";
   $flagselecthtml .= "<option value=\"\">Select Flag Image</option>";
   if ($handle=@opendir($urlofimages)) {
      while ($imgfile = readdir($handle)) {
         if ($imgfile != "." && $imgfile != ".." && $imgfile != "" && $imgfile != "index.html" && $imgfile != "WS_FTP.LOG" && $imgfile != "Thumbs.db") {
            if ($imgfile==$flag) {
               $flagselecthtml .= "<option value =\"$imgfile\" selected>$imgfile</option>";
            } else {
               $flagselecthtml .= "<option value =\"$imgfile\" >$imgfile</option>";
            }
         }
      }
      @closedir($handle);
   }
   $flagselecthtml .= "</select></td>";

// Load Weapons
   $weaponselecthtml = "<select name=\"weapon_id\">";
   $weaponselecthtml .= "<option value=\"\">Select Weapon</option>";
    $result3 = $db->sql_query("SELECT * FROM " . $prefix . "_milpacs_weapons order by make");
   while ($weaponrow = $db->sql_fetchrow($result3)) {
      if ($weaponrow[weapon_id]==$weapon_id) {
         $weaponselecthtml .= "<option value =\"$weaponrow[weapon_id]\" selected>$weaponrow[make]</option>";
      } else {
         $weaponselecthtml .= "<option value =\"$weaponrow[weapon_id]\" >$weaponrow[make]</option>";
      }
   }
   $weaponselecthtml .= "</select>";
// Load Unit
   $unitselecthtml = "<select name=\"unit_id\">";
   $unitselecthtml .= "<option value=\"\">Select Unit</option>";
    $result4 = $db->sql_query("SELECT * FROM " . $prefix . "_milpacs_units order by unit_name");
   while ($unitrow = $db->sql_fetchrow($result4)) {
      if ($unitrow[unit_id]==$unit_id) {
         $unitselecthtml .= "<option value =\"$unitrow[unit_id]\" selected>$unitrow[unit_name]</option>";
      } else {
         $unitselecthtml .= "<option value =\"$unitrow[unit_id]\" >$unitrow[unit_name]</option>";
      }
   }
   $unitselecthtml .= "</select>";

   // Load Unit
$unitselecthtml = "<select name=\"unit_id\">";
$unitselecthtml .= "<option value=\"\">Select Unit</option>";
$result4 = $db->sql_query("SELECT * FROM " . $prefix . "_milpacs_units order by unit_name");
while ($unitrow = $db->sql_fetchrow($result4)) {
   if ($unitrow[unit_id]==$unit_id) {
      $unitselecthtml .= "<option value =\"$unitrow[unit_id]\" selected>$unitrow[unit_name]</option>";
   } else {
      $unitselecthtml .= "<option value =\"$unitrow[unit_id]\" >$unitrow[unit_name]</option>";
   }
}
$unitselecthtml .= "</select>";

// Load Status
$statusselecthtml = "<select name=\"status\">\n<option value=\"\">Select Status</option>";
$wStatus = array("Active", "LOA", "Medical LOA", "Retired", "Discharged");
for ($i=0; $i < sizeof($wStatus); $i++) {
   if ($status == $wStatus[$i])
      $statusselecthtml .= "<option value='$wStatus[$i]' selected>$wStatus[$i]</option>";
   else
      $statusselecthtml .= "<option value='$wStatus[$i]'>$wStatus[$i]</option>";
}
$statusselecthtml .= "</select>";
      
?>

<form name="addsoldier" action="modules.php?name=<?php echo $module_name ?>" method="POST">
<table width="100%" border="2" cellpadding="2" align="center" cellspacing="0" style="border-collapse: collapse;" bgcolor="#555555" bordercolor="#111111">
   <tr>
      <td align="center" bgcolor="#777777">
      <b><font color="#000000">Add a new Soldier!</font></b>
      </td>
   </tr>
   <tr>
      <td align="center" bgcolor="#777777"> Uniform image: <?php echo $uniformselecthtml ?></td>
   </tr>
   <tr>
      <td align="center" bgcolor="#777777"> Rank image: <?php echo $rankselecthtml ?></td>
   </tr>
   <tr>
      <td align="center" bgcolor="#777777"> Flag image: <?php echo $flagselecthtml ?></td>
   </tr>
</table>
<table width="100%" border="2" cellpadding="2" align="center" cellspacing="0" style="border-collapse: collapse;" bgcolor="#555555" bordercolor="#111111">
   <tr>
      <td height="25" colspan="2" align="left" bgcolor="#666633">
      <b><font color="#000000">Vital Statistics</font></b>
      </td>
   </tr>
   <tr>
      <td align="center" bgcolor="#999999">
</table>
<table width="100%" border="1" cellpadding="2" cellspacing="1" style="border-collapse: collapse;" id="AutoNumber1" bordercolor="#111111">
       </td>
   </tr>
   <tr>
          <td width="50%" align="right"><b><font color="#660033">Name:</font></b></td>
          <td width="50%"><input type="text" name="name"></td>
    </tr>
   <tr>
      <td width="50%" align="right">
      <b><font color="#660033">Location:</font></b>
      </td>
      <td width="50%">
      <input type="text" name="location" value="<?php echo $location ?>"/>
      </td>
   </tr>
   <tr>
      <td width="50%" align="right">
      <b><font color="#660033">Status:  </font></b>
      </td>
      <td width="50%">
      <?php echo $statusselecthtml ?>
      </td>
   </tr>
   <tr>
      <td width="50%">
      <p align="right"><font color="#660033"><b>Primary MOS:</b></font>
      </td>
      <td width="50%">
      <input type="text" name="p_mos" value="<?php echo $p_mos ?>"/>
      </td>
   </tr>
   <tr>
      <td width="50%" align="right">
      <b><font color="#660033">Combat Unit:</font></b>
      </td>
      <td width="50%">
      <?php echo $unitselecthtml ?>
      </td>
   </tr>
   <tr>
      <td width="50%">
      <p align="right"><font color="#660033"><b>Reports to:</b></font>
      </td>
      <td width="50%">
      <input type="text" name="reports" value="<?php echo $reports ?>"/>
      </td>
   </tr>
   <tr>
      <td width="50%" align="right">
      <b><font color="#660033">Position:</font></b>
      </td>
      <td width="50%">
      <input type="text" name="position" value="<?php echo $position ?>"/>
      </td>
   </tr>
   <tr>
      <td width="50%" align="right">
      <font color="#660033"><b>Weapon:</b></font>
      </td>
      <td width="50%">
      <?php echo $weaponselecthtml ?>
      </td>
   </tr>
    <tr>
      <td width="50%" align="right">
      <b><font color="#660033">Enlisted Date:</font></b>
      </td>
      <td width="50%">
      <input type="text" name="enlistment_dt" value="<?php echo $enlistment_dt ?>"/>
      <a href="javascript:showCal('Enlistment');"><img src="images/javascript/calendar.jpg" title="Select Date" alt="Select Date"></a>
      </td>
   </tr>
   <tr>
      <td width="50%" align="right">
      <b><font color="#660033">ICQ#:  </font></b>
      </td>
      <td width="50%">
      <input type="text" name="icq" value="<?php echo $icq ?>"/>
      </td>
   </tr>   
</table>
<br>
<input type="hidden" name="op" value="addsoldier"/>
<input type="hidden" name="id" value="<?php echo $id ?>"/>
<input type="submit" class="button" align="center" value="Add"/>
</form>
<?php
CloseTable();
@include_once("footer.php");
?>
 
kguske







PostPosted: Sat Sep 24, 2005 9:37 pm Reply with quote

That's your addsoldier.php page, right? I noticed you have a form field called name - this will conflict with the nuke modules name. Change it to something like soldierName (and make sure all the other places where $name is used also change).
 
kguske







PostPosted: Sat Sep 24, 2005 9:40 pm Reply with quote

And, you can't use
Code:
$module_name = basename(dirname(__FILE__));
with a file in the admin directory below the module directory. That's why it's setting $module_name to admin.
 
kguske







PostPosted: Sat Sep 24, 2005 9:44 pm Reply with quote

If you have $module_name defined in the modules/MILPACS/index.php file (you can use the basename(dirname(__FILE__)) code there), then you don't need to set it here.

Just comment out that line in your modules/MILPACS/admin/addsoldier.php file after making sure its in modules/MILPACS/index.php.
 
Donovan







PostPosted: Sat Sep 24, 2005 9:56 pm Reply with quote

Yes $module_name is defined in the modules/MILPACS/index.php

Made these changes and still get:

Sorry, that module file was not found.
 
kguske







PostPosted: Sat Sep 24, 2005 9:58 pm Reply with quote

What URL is displayed after you submit from the addsoldier.php page?
 
Donovan







PostPosted: Sat Sep 24, 2005 10:13 pm Reply with quote

[ Only registered users can see links on this board! Get registered or login! ]
 
kguske







PostPosted: Sat Sep 24, 2005 10:21 pm Reply with quote

so it's missing the op parameter. That should still be a hidden field in your form and set to "addsoldier", right?
 
Donovan







PostPosted: Sat Sep 24, 2005 10:40 pm Reply with quote

Correct

<input type="hidden" name="op" value="addsoldier"/>
 
kguske







PostPosted: Sat Sep 24, 2005 10:51 pm Reply with quote

Without seeing the index.php file, it could be tricky. Try this in addsoldier:
Code:
<form name="addsoldier" action="modules.php?name=<?php echo $module_name ?>&op=addsoldier&file=" method="POST">
 
Donovan







PostPosted: Sat Sep 24, 2005 11:00 pm Reply with quote

My index.php has the following.

Code:


case "addsoldier":
      @include_once("modules/MILPACS/admin/addsoldier.php");
      break;
 
kguske







PostPosted: Sat Sep 24, 2005 11:05 pm Reply with quote

Right - but there could be other things causing the message. By forcing the parameters in the form action as I suggested in the previous post, we will know more...
 
Donovan







PostPosted: Sun Sep 25, 2005 9:35 am Reply with quote

The page cannot be displayed
The page you are looking for is currently unavailable.
[ Only registered users can see links on this board! Get registered or login! ]
 
kguske







PostPosted: Sun Sep 25, 2005 10:28 am Reply with quote

I added a command to use for testing. It indicates that the logic is correct in index.php. Next, I added a command to test that it was correctly accessing addsoldier in the admin directory. It was.

The problem appears to be in the addsoldier.php file. Can you make me a member of one of the groups 1, 10, 23?
 
kguske







PostPosted: Sun Sep 25, 2005 10:51 am Reply with quote

I found a few problems. The one that caused the unable to load file error was an include inside addsoldier.php for the same file. I commented that out.

The form had another issue. It was using the same op value to submit the data as it was to display the new form. The program had no way to determine when it needed to insert the record (i.e. it would keep displaying the same form without adding the record).

So I changed the value of op to be saveSoldier (note the capital S - it's different from the savesoldier op in the editsoldier.php file) and changed the index.php to treat saveSoldier like addsoldier.

Give her a spin now...
 
Donovan







PostPosted: Sun Sep 25, 2005 11:14 am Reply with quote

Sorry, that module file was not found.

You are in group 23


Last edited by Donovan on Sun Sep 25, 2005 11:20 am; edited 1 time in total 
kguske







PostPosted: Sun Sep 25, 2005 11:16 am Reply with quote

I pull up this link fine: [ Only registered users can see links on this board! Get registered or login! ]

Do you see that when you submit?
 
Display posts from previous:       
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> Modules

View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB © 2001-2007 phpBB Group
All times are GMT - 6 Hours
 
Forums ©