...

View Full Version : nothing in $_POST array



qwertyjjj
06-27-2008, 03:06 PM
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?



<?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>

CFMaBiSmAd
06-27-2008, 03:50 PM
Your HTML is invalid. The </form> tag is before the </select> tag.

barkermn01
06-27-2008, 04:02 PM
all data in the post has to be told to post from the html
E.G 1


<form action="" method="post">
</form>
What is your name:<input type="text" name="name" />
<input type="submit" value="Click">

all the data out side of the form will allways be sent via get to the page you are currently on

E.G 2


<form action="">
What is your name:<input type="text" name="name" />
<input type="submit" value="Click">
</form>

this will do the same as the last one but we can change where it sends the data to via the get with the action="&#37;page%"

E.G 3


<form action="" method="post">
What is your name:<input type="text" name="name" />
<input type="submit" value="Click">
</form>

This will send all data via port to the same file as loaded in and page can be changed via action="%page%"

E.G 4


What is your name:<input type="text" name="name" />
<form action="" method="post">
What is your password:<input type="password" name="pass" />
<input type="button" value="Click">
</form>


this would send the password though post and the name via get now you dont want to be using $_GET and $_POST just user $_REQUEST - this will check get and post data for the inforation u require this had to be done on the same page as the html is this is why we use isset() lol

E.G


<?php
if(isset($_REQUEST['name'])){
%do php work%
}else{
echo ' %HTML Code Here%';
}
?>

Fou-Lu
06-27-2008, 04:28 PM
Ummm... what?
CFM is talking about your actual html form embedding. You cannot have a <form><select></form></select>. Form doesn't see the select as being valid. _REQUEST is a poorly controlled superglobal, make sure you are creating your own custom request, otherwise you may get a surprise cookie out of it. Best I can see, you don't actually have any submit inputs either.

Ah, nvm about the input, you're using js for that. I'd still use a submit input though...



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum