|
-
June 27th, 2008, 08:06 AM
#1
nothing in $_POST array
Nothing appear in the query_creditcontroller array when I run this code. There's a bif javascript that submits it. Also, I can't use get for some reason, the javascript doesn't like it?
Code:
<?php
error_reporting(E_ALL ^ E_NOTICE);
include_once("checklogin.php");
include_once("db.php");
include_once("commonFunctions.php");
if (isset($_POST['query_creditcontroller'])) {
//update the CreditControllers table
/*
$resultMonths = mssql_query("UPDATE CreditControllers
SET CreditConName = '".substr($_POST['query_creditcontroller'],5,25)."'
WHERE CostCentre = '".substr($_POST['query_creditcontroller'],0,4)."'
AND MonthData = 0
") or die(mssql_get_last_message());
*/
echo substr($_POST['query_creditcontroller'],5,25)."<br />";
echo substr($_POST['query_creditcontroller'],0,4);
print_r($_POST);
}
$result = mssql_query("EXEC web_GetCreditControllers") or die(mssql_get_last_message());
$selected = mssql_select_db("KPI_DEV", $dbhandle)
or die("Couldn't open database $myDB");
$resultMonths = mssql_query("EXEC kpi_GetMonthData") or die(mssql_get_last_message());
?>
<link rel="stylesheet" type="text/css" href="styles1.css" />
<style>
input.dropdown {width: 300px;}
input.go {width: 50px;}
</style>
<table style='font-weight:bold; width:100%;border-width: 2px 2px 2px 2px;border-color: black black black black;' cellpadding='0' cellspacing='0' border='1'>
<tr>
<td style='vertical-align:middle;text-align:center;border-width: 0px 0px 0px 0px;width:1%;'><a class ='2' href='index.php'><img src='images/HomeIcon.png' alt='Return to main menu'></a></td>
<td style='padding: 0em 0em 0em 0em; background-color:white;border-width: 0px 0px 0px 0px;' colspan='10'>
<img src='images/logo.gif'>
<img src='images/picture.jpg'></td>
</tr>
</table>
<br />
<center>
Note: The KPI data must be imported for the new month before you can allocate the appropriate cost centre for a controller.
<form action='allocation.php' method='post'>
<select id='month' name='month' style='width:15%;' onChange='this.form.submit();'>
<?
echo "<option>--- Month ---</option>";
while ($rowMonths=mssql_fetch_assoc($resultMonths))
{
echo "<option value='".$rowMonths['MonthDataInt'].",".$rowMonths['MonthName']." ".$rowMonths['Year']."'>".$rowMonths['MonthName']." ".$rowMonths['Year']."</option>";
}
?>
</select>
</form>
<hr style='width:100%;'>
<br />
Note: the allocation in CMS for companies or cost centre splits will always override this data. For example, ZDTI, ASDA, Cumbria County Council, etc.
<br />
<?
if (isset($_POST['month'])) {
$month = 0;
if (substr($_POST['month'],0,1) == '-') {$month = substr($_POST['month'],0,2);} else {$month = substr($_POST['month'],0,1);}
$res_CC = mssql_query("EXEC bonus_ListControllerAllocation $month") or die(mssql_get_last_message());
echo "<br /><table cellpadding='2' width='400'>";
echo "<tr class='orange'><td colspan='3' align='center'>Allocation</td></tr>";
echo "<tr class='maintable'><th>Cost Centre</th><th>Controller</th><th>Change to:</th>";
$toggle = 0;
while($row = mssql_fetch_array($res_CC))
{
$costcentre = $row['CostCentre'];
if ($toggle == 0) {echo "<tr class='lightblue'>";} else {echo "<tr class='grey'>";}
echo "<td>".$costcentre."</td><td>".$row['CreditConName']."</td><td>";
?>
<form action='allocation.php' method='post'>
<select id='query_creditcontroller' name = 'query_creditcontroller' width='100%' onChange='this.form.submit();'>
<option id='cc' name = 'cc' value=''>Choose controller</option>
<?
mssql_data_seek($result, 0);
while($row2 = mssql_fetch_array($result))
{
echo "<option id='cc' name = 'cc' value='".$costcentre.",".$row2['CreditConName']."'>".$row2['CreditConName']."</option>";
}
?>
</form>
</select>
<?
echo "</tr>";
if ($toggle == 0) {$toggle++;} else {$toggle--;}
}
echo "</table>";
}
?>
</center>
-
June 27th, 2008, 08:30 AM
#2
Re: nothing in $_POST array
Basic rule that is always true: $_POST will never return empty if it isn't.
I noticed that you first include checklogin.php. My first guess would be that this php file is registering the user as not logged in. Then, it probably redirects the user therefore all post variables would be destroyed. Could this be the case?
Either way, it is hard to test it because we don't have your database nor the included files. And that would be more work to get testing than we have time.
If the post was helpful...Rate it! Remember to use [code] or [php] tags.
-
June 27th, 2008, 08:45 AM
#3
Re: nothing in $_POST array
I think the problem lies in the form somewhere or the submission of it but I can't see it.
checklogin.php is fine as I wouldn't have access to the page at all. For safety, I have commented it out but same problem happens.
The option buttons have values in them, I have checked the HTML source so it;s not that either.
Just prints Array ( [query_creditcontroller] => )
-
June 27th, 2008, 09:02 AM
#4
Re: nothing in $_POST array
Notice that you close the <form> tag before you close the <select> tag. You might want to fix that.
If the post was helpful...Rate it! Remember to use [code] or [php] tags.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|