Re: get or post
- From: JRough <jlrough@xxxxxxxxx>
- Date: Wed, 31 Dec 2008 13:14:08 -0800 (PST)
On Dec 30, 8:53 pm, FutureShock <futuresho...@xxxxxxx> wrote:
JRough wrote:I hate this whole page. do you mean the whole page with the
On Dec 30, 7:45 pm, FutureShock <futuresho...@xxxxxxx> wrote:
Acutally I was wrong....PHP_SELF should return the doc path.
http://example.com/members/test.php
will return '/members/test.php'
Scotty
So that means the id does get posted for the "all cars". That means
it is available on any page in the session. It is posting it through
the url not through the form. Is that why it doesn't matter that the
end </form> tag was missing and it worked anyway? So that is not the
problem then. For some reason my redirect to the excel page works for
the customer user and not the internal or owner user. It does not
redirect to current_sightingsXL.php in the case of the owner or
internal user only the customer user. The only other difference
between those 2 users and the customer user is the select_lease_num
(leaseID) & select_comp_name(leaseID) functions.
Validate_login("current_sightings.php");
if(empty($id)&&($_SESSION["LMS_USER_DESC"]=='internal'||$_SESSION
["LMS_USER_DESC"]=='owner')){
# THIS IS id INSTEAD OF lease_id B/C ONE DAY WE MIGHT HAVE CUSTOMER
SUB GROUPS OR MANAGED CARS
$destroyed = GetDestroyed_lease_id();
$result = Get_leasesCLM();
$TPL_ids = "<SELECT name='id' class=box size=8>\n";
$trbg = "";
while($row = mysql_fetch_assoc($result)){
$id = $row['lease_id'];
$lnum = $row['lease_num'];
$comp = $row['comp_name'];
$trbg = GetTRBG($trbg);
$TPL_ids.=" <OPTION VALUE='".$id;
$TPL_ids.="' ".$trbg.">".$lnum." - ".$comp."</OPTION>\n";
}
$TPL_ids.="</SELECT>\n";
include "header.php";
include $template_path."current_sightings_php.html";
}elseif($_POST['redirect']&&$_POST['redirect']!=$_SERVER['PHP_SELF']){
Header("Location: ".$_POST['redirect'].".php?id=".$_POST['id']);
exit;
}elseif($_POST['assign']=='Open in Excel'){
#Header("Location: http://allcapitalrail.com/current_sightingsXL.php");
Header("Location: http://allcapitalrail.com/current_sightingsXL.php?id=".$_POST['id']);
exit;
}else{
# DETERMINE PAGE ACCORDING TO USER TYPE
switch ($_SESSION["LMS_USER_DESC"]){
case "customer":
$id = $_SESSION["LMS_LOGGED_IN"];
$MSG_carlist = "CURRENT SIGHTINGS";
$result = SELECT_sightings_customercars($id,CLM_order_by
($order_by));
break;
case "internal":
$MSG_carlist = "CURRENT SIGHTINGS FOR ".SELECT_lease_num($id)."
".SELECT_comp_name($id);
$result = SELECT_sightings_leasecars($id,CLM_order_by
($order_by));
break;
case "owner":
$MSG_carlist = "CURRENT SIGHTINGS FOR ".SELECT_lease_num($id)."
".SELECT_comp_name($id);
$result = SELECT_sightings_ownercars($id,CLM_order_by
($order_by));
break;
#case "internal_ltd":
# break;
}
$TPL_carnumbers = GetTableHeaders($id);
while ($row = mysql_fetch_assoc($result)){
$TPL_carnumbers.=MakeSighting($row);
}
$TPL_carnumbers.="</table>";
include "header.php";
include $template_path."template_carlist.html";
include "footer.php";
}
-------------
function SELECT_lease_num($lease_id){
$query = "SELECT m.lease_num
FROM INTERNAL_MASTER_LEASE m, INTERNAL_LEASES l
WHERE l.lease_id =".$lease_id."
AND l.master_lease_id = m.master_lease_id";
$result = mysql_query($query);
if(!$result){
MySQLError($query);
exit;
}
$row = mysql_fetch_row($result);
return $row[0];
}
function SELECT_comp_name($lease_id){
$query = "SELECT comp_name
FROM INTERNAL_LEASES l, INTERNAL_MASTER_LEASE m, INTERNAL_COMPANY
c
WHERE l.lease_id = ".$lease_id."
AND l.master_lease_id = m.master_lease_id
AND m.comp_id = c.comp_id";
$result = mysql_query($query);
if(!$result){
MySQLError($query);
exit;
}
$row = mysql_fetch_row($result);
return $row[0];
}
With this statement:
}elseif($_POST['assign']=='Open in Excel'){
#Header("Location: http://allcapitalrail.com/current_sightingsXL.php");
Header("Location:http://allcapitalrail.com/current_sightingsXL.php?id=".$_POST['id']);
exit;
I don't see from this page or the last form where you are setting a
$_POST variable to 'Open in Excel'.
If you could post the entire page, it may be easier to decrypt.
Scotty
PS: I hate templates.
queries? There are two templates. The first if statement has the
current sightings template. It creates the form were the user makes
the id selection. The other template the carlist is from the case
statement and prints the car sighting lists. I just put the post in
that excel header just trying to trouble shoot it. It probably
doesn't need it. I think it is already posted in the first elseif?
The reason is the queries work and they require the id.
<?php
include './includes/config.inc.php';
include $include_path.'dates.inc.php';
include_once $include_path."LMS_functions.inc.php";
#// ###############################################
#// Is the user logged in?
Validate_login("current_sightings.php");
if(empty($id)&&($_SESSION["LMS_USER_DESC"]=='internal'||$_SESSION
["LMS_USER_DESC"]=='owner')){
# THIS IS id INSTEAD OF lease_id B/C ONE DAY WE MIGHT HAVE CUSTOMER
SUB GROUPS OR MANAGED CARS
$destroyed = GetDestroyed_lease_id();
$result = Get_leasesCLM();
$TPL_ids = "<SELECT name='id' class=box size=8>\n";
$trbg = "";
while($row = mysql_fetch_assoc($result)){
$id = $row['lease_id'];
$lnum = $row['lease_num'];
$comp = $row['comp_name'];
$trbg = GetTRBG($trbg);
$TPL_ids.=" <OPTION VALUE='".$id;
$TPL_ids.="' ".$trbg.">".$lnum." - ".$comp."</OPTION>\n";
}
$TPL_ids.="</SELECT>\n";
include "header.php";
include $template_path."current_sightings_php.html";
}elseif($_POST['redirect']&&$_POST['redirect']!=$_SERVER['PHP_SELF']){
Header("Location: ".$_POST['redirect'].".php?id=".$_POST['id']);
exit;
}elseif($_POST['assign']=='Open in Excel'){
#Header("Location: http://allcapitalrail.com/current_sightingsXL.php");
Header("Location: http://allcapitalrail.com/current_sightingsXL.php?id=".$_POST['id']);
exit;
}else{
# DETERMINE PAGE ACCORDING TO USER TYPE
switch ($_SESSION["LMS_USER_DESC"]){
case "customer":
$id = $_SESSION["LMS_LOGGED_IN"];
$MSG_carlist = "CURRENT SIGHTINGS";
$result = SELECT_sightings_customercars($id,CLM_order_by
($order_by));
break;
case "internal":
$MSG_carlist = "CURRENT SIGHTINGS FOR ".SELECT_lease_num($id)."
".SELECT_comp_name($id);
$result = SELECT_sightings_leasecars($id,CLM_order_by
($order_by));
break;
case "owner":
$MSG_carlist = "CURRENT SIGHTINGS FOR ".SELECT_lease_num($id)."
".SELECT_comp_name($id);
$result = SELECT_sightings_ownercars($id,CLM_order_by
($order_by));
break;
#case "internal_ltd":
# break;
}
$TPL_carnumbers = GetTableHeaders($id);
while ($row = mysql_fetch_assoc($result)){
$TPL_carnumbers.=MakeSighting($row);
}
$TPL_carnumbers.="</table>";
include "header.php";
include $template_path."template_carlist.html";
include "footer.php";
/* if ($_POST['assign']=='Open in Excel'){
#header("Location: current_sightingsXL.php");
echo "<meta http-equiv='Refresh' content='0;
url=current_sightingsXL.php'>";
exit;
}*/
}
######################################
##
## FUNCTIONS
##
######################################
function Get_leasesCLM(){
if($_SESSION["LMS_USER_DESC"]=='owner'){
$result = SELECT_owner_leasesCLM();
}else{
$result = SELECT_leasesCLM();
}
return $result;
}
function GetTableHeaders($id){
return "<table>
<th><a href='current_sightings.php?id=".$id."&order_by=l_e'>L_E</
a></th>
<th><a href='current_sightings.php?id=".$id."&'>Carnumber</a></th>
<th>Type</th>
<th><a href='current_sightings.php?id=".
$id."&order_by=location'>Location</a></th>
<th><a href='current_sightings.php?id=".
$id."&order_by=sighting_date'>Sighting Date</a></th>
<th><a href='current_sightings.php?id=".
$id."&order_by=classification'>Code</a></th>
<th><a href='current_sightings.php?id=".
$id."&order_by=railroad'>RR</a></th>
<th><a href='current_sightings.php?id=".
$id."&order_by=origin'>Origin</a></th>
<th><a href='current_sightings.php?id=".
$id."&order_by=destination'>Destination</a></th>
<th><a href='current_sightings.php?id=".$id."&order_by=eta'>ETA</
a></th>";
}
function GetCars($id,$type,$order_by){
switch($type){
case 'lease':
return SELECT_sightings_leasecars($id,$order_by);
break;
default:
return SELECT_sightings_leasecars($id,$order_by);
break;
}
}
function MakeSighting($row){
$mark = $row['car_mark'];
$num = $row['car_number'];
$l_e = $row['l_e'];
$carnumber = MakeCarnumber($mark,$num);
$location = MakeCity($row['location_city'],$row['location_state']);
$sighting_date = $row['sighting_date'];
$classification = $row['classification'];
$railroad = $row['railroad'];
$origin = MakeCity($row['origin_city'],$row['origin_state']);
$destination = MakeCity($row['destination_city'],$row
['destination_state']);
$eta = $row['eta'];
if($l_e=='L'){
$trbg = "class='trbg'";
}else{
$trbg = "";
}
return "<tr ".$trbg.">
<td align='center'>".$l_e."</td>
<td><a href='clm_history.php?mark=".$mark."&num=".$num."'>".
$carnumber."</a></td>
<td align='center'>".GetMechanicalDesignationCarnumber($mark,
$num)."</td>
<td>".$location."</td>
<td>".CLM_dateFormat($sighting_date)."</td>
<td>".$classification."</td>
<td>".$railroad."</td>
<td>".$origin."</td>
<td>".$destination."</td>
<td align='center'>".Display_ETA($location,$destination,$eta)."</
td>
</tr>";
}
################################
##
## QUERIES
##
################################
function SELECT_owner_leasesCLM(){
$query = "SELECT DISTINCT l.lease_id, m.lease_num, co.comp_name
FROM INTERNAL_LEASES l, INTERNAL_MASTER_LEASE m, INTERNAL_COMPANY
co,
INTERNAL_CAR_LEASE cl, LAST_SIGHTING ls, INTERNAL_REMARK r,
INTERNAL_CUSTOMER_USERS cu, INTERNAL_CAR_OWNER caro
WHERE co.comp_id = m.comp_id
AND m.master_lease_id = l.master_lease_id
AND l.lease_id = cl.lease_id
AND cl.end_date IS NULL
AND cl.remark_id = ls.remark_id
AND ls.remark_id = r.remark_id
AND r.car_id = caro.car_id
AND caro.end_date IS NULL
AND caro.comp_id = cu.comp_id
AND cu.id = ".$_SESSION["LMS_LOGGED_IN"]."
ORDER BY comp_name, lease_num";
$result = mysql_query($query);
if(!$result){
MySQLError($query);
exit;
}
return $result;
}
function SELECT_leasesCLM(){
$query = "SELECT DISTINCT l.lease_id, m.lease_num, co.comp_name
FROM INTERNAL_LEASES l, INTERNAL_MASTER_LEASE m, INTERNAL_COMPANY
co,
INTERNAL_CAR_LEASE cl, LAST_SIGHTING ls
WHERE co.comp_id = m.comp_id
AND m.master_lease_id = l.master_lease_id
AND l.lease_id = cl.lease_id
AND cl.end_date IS NULL
AND cl.remark_id = ls.remark_id
ORDER BY comp_name, lease_num";
$result = mysql_query($query);
if(!$result){
MySQLError($query);
exit;
}
return $result;
}
function SELECT_lease_num($lease_id){
$query = "SELECT m.lease_num
FROM INTERNAL_MASTER_LEASE m, INTERNAL_LEASES l
WHERE l.lease_id =".$lease_id."
AND l.master_lease_id = m.master_lease_id";
$result = mysql_query($query);
if(!$result){
MySQLError($query);
exit;
}
$row = mysql_fetch_row($result);
return $row[0];
}
function SELECT_comp_name($lease_id){
$query = "SELECT comp_name
FROM INTERNAL_LEASES l, INTERNAL_MASTER_LEASE m, INTERNAL_COMPANY
c
WHERE l.lease_id = ".$lease_id."
AND l.master_lease_id = m.master_lease_id
AND m.comp_id = c.comp_id";
$result = mysql_query($query);
if(!$result){
MySQLError($query);
exit;
}
$row = mysql_fetch_row($result);
return $row[0];
}
function SELECT_sightings_customercars($id,$order_by){
$query = "SELECT c.l_e,
c.car_mark, c.car_number,
c.location_city, c.location_state,
c.sighting_date,
e.classification,
c.railroad,
s.city as origin_city,
s.state as origin_state,
c.destination_city, c.destination_state,
t.eta
FROM INTERNAL_CUSTOMER_USERS cu, all_cars_view a, LAST_SIGHTING
ls, INTERNAL_CODES e, INTERNAL_CLM c
LEFT JOIN (INTERNAL_TRIPS t, INTERNAL_SPLC s)
ON (c.trip_id = t.trip_id
AND t.origin_splc_id = s.splc_id)
WHERE cu.id = ".$id."
AND cu.comp_id = a.comp_id
AND a.remark_id = ls.remark_id
AND ls.clm_id = c.clm_id
AND c.sighting_code = e.code
ORDER BY ".$order_by;
$result = mysql_query($query);
if(!$result){
MySQLError($query);
exit;
}
return $result;
}
function SELECT_sightings_leasecars($lease_id='74',$order_by){
$query = "SELECT c.l_e,
c.car_mark, c.car_number,
c.location_city, c.location_state,
c.sighting_date,
e.classification,
c.railroad,
s.city as origin_city,
s.state as origin_state,
c.destination_city, c.destination_state,
t.eta
FROM LAST_SIGHTING ls, INTERNAL_CAR_LEASE cl,INTERNAL_CODES e,
INTERNAL_CLM c
LEFT JOIN (INTERNAL_TRIPS t, INTERNAL_SPLC s)
ON (c.trip_id = t.trip_id
AND t.origin_splc_id = s.splc_id)
WHERE cl.lease_id = ".$lease_id."
AND cl.end_date IS NULL
AND cl.remark_id = ls.remark_id
AND ls.clm_id = c.clm_id
AND c.sighting_code = e.code
ORDER BY ".$order_by;
$result = mysql_query($query);
if(!$result){
MySQLError($query);
exit;
}
return $result;
}
function SELECT_sightings_ownercars($lease_id='74',$order_by){
$query = "SELECT c.l_e,
c.car_mark, c.car_number,
c.location_city, c.location_state,
c.sighting_date,
e.classification,
c.railroad,
s.city as origin_city,
s.state as origin_state,
c.destination_city, c.destination_state,
t.eta
FROM INTERNAL_REMARK r, INTERNAL_CAR_LEASE cl,
INTERNAL_CUSTOMER_USERS cu, INTERNAL_CAR_OWNER caro,
LAST_SIGHTING ls, INTERNAL_CODES e, INTERNAL_CLM c
LEFT JOIN (INTERNAL_TRIPS t, INTERNAL_SPLC s)
ON (c.trip_id = t.trip_id
AND t.origin_splc_id = s.splc_id)
WHERE cl.lease_id = ".$lease_id."
AND cl.end_date IS NULL
AND cl.remark_id = r.remark_id
AND r.car_id = caro.car_id
AND caro.end_date IS NULL
AND caro.comp_id = cu.comp_id
AND cu.id = ".$_SESSION["LMS_LOGGED_IN"]."
AND r.remark_id = ls.remark_id
AND ls.clm_id = c.clm_id
AND c.sighting_code = e.code
ORDER BY ".$order_by;
$result = mysql_query($query);
if(!$result){
MySQLError($query);
exit;
}
return $result;
}
?>
.
- References:
- get or post
- From: JRough
- Re: get or post
- From: FutureShock
- Re: get or post
- From: JRough
- Re: get or post
- From: FutureShock
- get or post
- Prev by Date: Re: public library script
- Previous by thread: Re: get or post
- Next by thread: image sizing/cropping
- Index(es):
Relevant Pages
|