Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New Coder
    Join Date
    Dec 2007
    Posts
    65
    Thanks
    1
    Thanked 0 Times in 0 Posts

    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>

  • #2
    Senior Coder CFMaBiSmAd's Avatar
    Join Date
    Oct 2006
    Location
    Denver, Colorado USA
    Posts
    3,063
    Thanks
    2
    Thanked 317 Times in 309 Posts
    Your HTML is invalid. The </form> tag is before the </select> tag.
    If you are learning PHP, developing PHP code, or debugging PHP code, do yourself a favor and check your web server log for errors and/or turn on full PHP error reporting in php.ini or in a .htaccess file to get PHP to help you.

  • #3
    Regular Coder
    Join Date
    Nov 2007
    Location
    Leeds, UK
    Posts
    514
    Thanks
    24
    Thanked 19 Times in 19 Posts
    all data in the post has to be told to post from the html
    E.G 1
    PHP Code:
    <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
    PHP Code:
    <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
    PHP Code:
    <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
    PHP Code:
    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 Code:
    <?php
    if(isset($_REQUEST['name'])){
       %do 
    php work%
    }else{
    echo 
    ' %HTML Code Here%';
    }
    ?>
    Last edited by barkermn01; 06-27-2008 at 03:07 PM.

  • #4
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    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...
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 
    Been gone for a few months, and haven't programmed in that long of a time. Meh, I'll wing it ;)


  •  

    Posting Permissions

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