There have a form in a view page that take data as a multidimensional array.In edit mode that form value is fetching and showing data through a foreach loop.
Now my problem is i'm unable to modify that form data in that foreach loop and send it to database. I gone through some posts about foreach key concept but how do I take modified value here in html and send it to database within this foreach loop?
My code fetching data properly but fail to update data.
Here is my code of view page :
<table class="table table-striped" id="dataTable">
<thead>
<tr>
<th>Subscription</th>
<th>Description</th>
<th>Interval</th>
<th>Amount</th>
<th></th>
</tr>
</thead>
<tbody>
<?php
if (!empty($invoice_detail)) {
foreach ($invoice_detail as $key => $result) { ?>
<tr>
<td><input type="text" name="invoice[$key][invoice_detail_subs]" id="invoice_detail_subs"
value="<?php echo $result->invoice_detail_subs; ?>"/></td>
<td><input type="text" name="invoice[$key][invoice_detail_desc]" id="invoice_detail_desc"
value="<?php echo $result->invoice_detail_desc; ?>"/></td>
<td><input type="text" name="invoice[$key][invoice_detail_interval]" id="invoice_detail_interval"
value="<?php echo $result->invoice_detail_interval; ?>"/></td>
<td><input type="text" name="invoice[$key][invoice_detail_amount]" id="invoice_detail_amount"
value="<?php echo $result->invoice_detail_amount; ?>"/></td>
<td></td>
</tr>
<?php }
} ?>
</tbody>
</table>
Here it is Update code in in controller :
if ($this->input->post('Submit')) {
$query = $this->db->query(
"SELECT * FROM ".$this->db->dbprefix."invoice_details WHERE invoice_detail_invoie_id ='".$id."' "
);
$fetch = $query->row();
$rows = $query->num_rows();
if ($id) {
$data1 = [
'invoice_detail_subs' => $this->input->post('invoice_detail_subs'),
'invoice_detail_desc' => $this->input->post('invoice_detail_desc'),
'invoice_detail_interval' => $this->input->post('invoice_detail_interval'),
'invoice_detail_amount' => $this->input->post('invoice_detail_amount'),
'invoice_detail_mddt' => date("Y-m-d H:i:s")
];
$this->db->update('invoice_details', $data1, 'invoice_detail_invoie_id = '.$id);
}
}
View Code
<table class="table table-striped" id="dataTable">
<thead>
<tr>
<th>Subscription</th>
<th>Description</th>
<th>Interval</th>
<th>Amount</th>
<th></th>
</tr>
</thead>
<tbody>
<?php
if (is_object($invoice_detail)) :
foreach ($invoice_detail as $key => $result) : ?>
<tr>
<td><input type="text" name="invoice_detail_subs"
value="<?= $result->invoice_detail_subs; ?>"/></td>
<td><input type="text" name="invoice_detail_desc"
value="<?= $result->invoice_detail_desc; ?>"/></td>
<td><input type="text" name="invoice_detail_interval"
value="<?= $result->invoice_detail_interval; ?>"/></td>
<td><input type="text" name="invoice_detail_amount"
value="<?= $result->invoice_detail_amount; ?>"/></td>
<td></td>
</tr>
<?php endforeach;
endif; ?>
</tbody>
update code in controller
if ($this->input->method()=="post") {
if ($id) {
$data1 = ['invoice_detail_subs'=> $this->input->post('invoice_detail_subs'),
'invoice_detail_desc' => $this->input->post('invoice_detail_desc'),
'invoice_detail_interval' => $this->input->post('invoice_detail_interval'),
'invoice_detail_amount' => $this->input->post('invoice_detail_amount'),
'invoice_detail_mddt' => date("Y-m-d H:i:s")];
$this->db->update($this->db->dbprefix."invoice_details", $data1,['invoice_detail_invoie_id'=>$id]);
}
}
$query = $this->db->select('*')->where(["invoice_detail_invoie_id"=>$id])->get($this->db->dbprefix."invoice_details");
$fetch = $query->row();
$rows = $query->num_rows();
I have a problem detecting the error which I'm receiving.
Warning: Invalid argument supplied for foreach()
I'm trying to display an object's entities which are stored using Phpmyadmin. I'm using an MVC architecture.
FormController:
public function run(){
$tabteachers='';
if(!empty($_SESSION['apply']) && !empty($_SESSION['application'])){
$tabteachers = DB::getInstance()->select_teacher_id($_SESSION['login']);
}
require_once(VIEW_PATH.'formdeux.php');
}
Db.class function():
public function select_teacher_id($login){
$query = 'SELECT * FROM teachers,internships,students WHERE teachers.email_teacher = internships.email_responsible_internship AND students.registry_number_student = internships.registry_student_internship AND internships.registry_student_internship = '. $this->_db->quote ( $login );
$result = $this->_db->query ( $query );
if ($result->rowcount () != 0) {
while ( $row = $result->fetch () ) {
$teacher[]= new teacher ( $row->email_teacher,$row->firstname_teacher,$row->lastname_teacher,$row->responsible_internship_teacher,NULL);
}
return $teacher;
}
}
Form View:
<table>
<thead>
<tr>
<th width="20%" class="decoration">contact</th>
</tr>
</thead>
<tbody>
<?php foreach ($tabteachers as $teacher) { ?>
<tr>
<td>Lastname: <td>
<input type="text" name="lastnamepro" value="<?php echo $teacher->lastname_teacher() ?>" size="100px">
</tr>
<tr>
<td>Firstname: <td>
<input type="text" name="firstnamepro" value="<?php echo $teacher->firstname_teacher() ?>" size="100px">
</tr>
<tr>
<td>Email address: <td>
<input type="text" name="emailpro" value="<?php echo $teacher->email_teacher() ?>" size="100px">
</tr>
<tr>
<td>Service: <td>
<input type="text" name="servicepro" value="null" size="100px">
</tr>
<tr>
<td>mobile number: <td>
<input type="text" name="phonenumberpro" value="aucun numero" size="100px">
</tr>
<?php } ?>
</tbody>
</table>
thanks for your help in advance!
I'm not that good in coding and I was wondering if anyone could help me. I am using PHP/MYSQL to create a form that includes radio buttons and drop down.
When I'm trying to test and insert record it says
"SORRY! ERROR while inserting record !"
This is my coding.
dbconfig.php
<?php
$DB_host = "localhost";
$DB_user = "root";
$DB_pass = "";
$DB_name = "dblogin";
try
{
$DB_con = new PDO("mysql:host={$DB_host};dbname={$DB_name}",$DB_user,$DB_pass);
$DB_con->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
}
catch(PDOException $e)
{
echo $e->getMessage();
}
include_once 'class.crud.php';
$crud = new crud($DB_con);
?>
add-data.php
<?php
include_once 'dbconfig.php';
if(isset($_POST['btn-save']))
{
$FteName = $_POST['FteName'];
$SalesMgr = $_POST['SalesMgr'];
$GEO = $_POST['GEO'];
$ProdMgr = $_POST['ProdMgr'];
$AeName = $_POST['AeName'];
$CustName = $_POST['CustName'];
$CustCat = $_POST['CustCat'];
$CustPoNum = $_POST['CustPoNum'];
$CustPoDate = $_POST['CustPoDate'];
$SalesQrt = $_POST['SalesQrt'];
$PaymentStat = $_POST['PaymentStat'];
$SONum = $_POST['SONum'];
$AmtPaid = $_POST['AmtPaid'];
$DatePaid = $_POST['DatePaid'];
$OppoGold = $_POST['OppoGold'];
$CheckBy = $_POST['CheckBy'];
if($crud->create($FteName=$SalesMgr=$GEO=$ProdMgr=$AeName=$CustName=$CustCat=$CustPoNum=$CustPoDate=$SalesQrt=$PaymentStat=$SONum=$AmtPaid=$DatePaid=$OppoGold=$CheckBy))
{
header("Location: add-data.php?inserted");
}
else
{
header("Location: add-data.php?failure");
}
}
?>
<?php include_once 'header.php'; ?>
<div class="clearfix"></div>
<?php
if(isset($_GET['inserted']))
{
?>
<div class="container">
<div class="alert alert-info">
<strong>Data successfully save. </strong>HOME!
</div>
</div>
<?php
}
else if(isset($_GET['failure']))
{
?>
<div class="container">
<div class="alert alert-warning">
<strong>SORRY!</strong> ERROR while inserting record !
</div>
</div>
<?php
}
?>
<div class="clearfix"></div><br />
<div class="container">
<form method='post'>
<table class='table table-bordered'>
<tr>
<td>FTE/SR Name:</td>
<td><input type='text' name='FteName' class='form-control' required></td>
</tr>
<tr>
<td>Sales Manager/Team Leader</td>
<td><input type='text' name='SalesMgr' class='form-control' required></td>
</tr>
<tr>
<td>GEO</td>
<td><input type='text' name='GEO' class='form-control' required></td>
</tr>
<tr>
<td>AE (Presales)</td>
<td><input type='text' name='AeName' class='form-control' required></td>
</tr>
<tr>
<td>Customer Name</td>
<td><input type='text' name='CustName' class='form-control' required></td>
</tr>
<tr>
<td>Customer Category</td>
<td><select name='CustCat' class='form-control' required>
<option value="New">New</option>
<option value="Installed Base">Installed Base</option>
<option value="DS-Reffered">DS Reffered</option>
<option value="DS-Old">DS-Old</option>
</select></td>
</tr>
<tr>
<td>Custom PO Number</td>
<td><input type='text' name='CustPoNum' class='form-control' required></td>
</tr>
<tr>
<td>Customer PO Date</td>
<td><input type='text' name='CustPoDate' class='form-control' required></td>
</tr>
<tr>
<td>SO Number</td>
<td><input type='text' name='SONum' class='form-control' required></td>
</tr>
<tr>
<td>Sales for Quarter</td>
<td><Input type = 'Radio' Name ='SalesQrt' value= '1st Quarter' />1st Quarter
<Input type = 'Radio' Name ='SalesQrt' value= '2nd Quarter' />2nd Quarter
<Input type = 'Radio' Name ='SalesQrt' value= '3rd Quarter' />3rd Quarter
<Input type = 'Radio' Name ='SalesQrt' value= '4th Quarter' />4th Quarter</td>
</tr>
<tr>
<td>Payment Status</td>
<td><Input type = 'Radio' Name ='PaymentStat' value= 'Yes' />Yes
<Input type = 'Radio' Name ='PaymentStat' value= 'No' />No</td>
</tr>
<tr>
<td>Amount Paid</td>
<td><input type='text' name='AmtPaid' class='form-control' required></td>
</tr>
<tr>
<td>Date Paid</td>
<td><input type='text' name='DatePaid' class='form-control' required></td>
</tr>
<tr>
<td>Enter in Goldmine?</td>
<td><Input type = 'Radio' Name ='OppoGold' value= 'Yes' />Yes
<Input type = 'Radio' Name ='OppoGold' value= 'No' />No</td>
</tr>
<tr>
<td>Verified/Checked By:</td>
<td><input type='text' name='CheckBy' class='form-control' required></td>
</tr>
<tr>
<td colspan="2">
<button type="submit" class="btn btn-primary" name="btn-save">
<span class="glyphicon glyphicon-plus"></span> SAVE
</button>
<i class="glyphicon glyphicon-backward"></i> Back to index
</td>
</tr>
</table>
</form>
</div>
class.crud.php
class crud
{
private $db;
function __construct($DB_con)
{
$this->db = $DB_con;
}
public function create($FteName,$SalesMgr,$GEO,$ProdMgr,$AeName,$CustName,$CustCat,$CustPoNum,$CustPoDate,$SalesQrt,$SONum,$AmtPaid,$AmtDatePaid,$OppoGold,$CheckBy)
{
try
{
$stmt = $this->db->prepare("INSERT INTO info(FteName,SalesMgr,GEO,ProdMgr,AeName,CustName,CustCat,CustPoNum,CustPoDate,SalesQrt,SONum,AmtPaid,AmtDatePaid,OppoGold,CheckBy) VALUES(:FteName, :SalesMgr, :GEO, :ProdMgr, :AeName, :CustName, :CustCat, :CustPoNum, :CustPoDate, :SalesQrt, :SONum, :AmtPaid, :AmtDatePaid, :OppoGold, :CheckBy)");
$stmt->bindparam(":FteName",$FteName);
$stmt->bindparam(":SalesMgr",$SalesMgr);
$stmt->bindparam(":GEO",$GEO);
$stmt->bindparam(":ProdMgr",$ProdMgr);
$stmt->bindparam(":AeName",$AeName);
$stmt->bindparam(":CustName",$CustName);
$stmt->bindparam(":CustCat",$CustCat);
$stmt->bindparam(":CustPoNum",$CustPoNum);
$stmt->bindparam(":CustPoDate",$CustPoDate);
$stmt->bindparam(":SalesQrt",$SalesQrt);
$stmt->bindparam(":SONum",$SONum);
$stmt->bindparam(":AmtPaid",$AmtPaid);
$stmt->bindparam(":AmtDatePaid",$AmtDatePaid);
$stmt->bindparam(":OppoGold",$OppoGold);
$stmt->bindparam(":CheckBy",$CheckBy);
$stmt->execute();
return true;
}
catch(PDOException $e)
{
echo $e->getMessage();
return false;
}
}
public function getID($infoID)
{
$stmt = $this->db->prepare("SELECT * FROM info WHERE infoID=:infoID");
$stmt->execute(array(":infoID"=>$infoID));
$editRow=$stmt->fetch(PDO::FETCH_ASSOC);
return $editRow;
}
public function update($infoID,$FteName,$SalesMgr,$GEO,$ProdMgr,$AeName,$CustName,$CustCat,$CustPoNum,$CustPoDate,$SalesQrt,$SONum,$AmtPaid,$AmtDatePaid,$OppoGold,$CheckBy)
{
try
{
$stmt=$this->db->prepare("UPDATE info SET FteName=:FteName,
SalesMgr=:SalesMgr,
GEO=:GEO,
ProdMgr=:ProdMgr,
AeName=:AeName,
CustName=:CustName,
CustCat=:CustCat,
CustPoNum=:CustPoNum,
CustPoDate=:CustPoDate,
SalesQrt=:SalesQrt,
SONum=:SONum,
AmtPaid=:AmtPaid,
AmtDatePaid=:AmtDatePaid,
OppoGold=:OppoGold,
CheckBy=:CheckBy
WHERE infoID=:infoID ");
$stmt->bindparam(":FteName",$FteName);
$stmt->bindparam(":SalesMgr",$SalesMgr);
$stmt->bindparam(":GEO",$GEO);
$stmt->bindparam(":ProdMgr",$ProdMgr);
$stmt->bindparam(":AeName",$AeName);
$stmt->bindparam(":CustName",$CustName);
$stmt->bindparam(":CustCat",$CustCat);
$stmt->bindparam(":CustPoNum",$CustPoNum);
$stmt->bindparam(":CustPoDate",$CustPoDate);
$stmt->bindparam(":SalesQrt",$SalesQrt);
$stmt->bindparam(":SONum",$SONum);
$stmt->bindparam(":AmtPaid",$AmtPaid);
$stmt->bindparam(":AmtDatePaid",$AmtDatePaid);
$stmt->bindparam(":OppoGold",$OppoGold);
$stmt->bindparam(":CheckBy",$CheckBy);
$stmt->execute();
return true;
}
catch(PDOException $e)
{
echo $e->getMessage();
return false;
}
}
public function delete($infoID)
{
$stmt = $this->db->prepare("DELETE FROM info WHERE infoID=:infoID");
$stmt->bindparam(":infoID",$infoID);
$stmt->execute();
return true;
}
/* paging */
public function dataview($query)
{
$stmt = $this->db->prepare($query);
$stmt->execute();
if($stmt->rowCount()>0)
{
while($row=$stmt->fetch(PDO::FETCH_ASSOC))
{
?>
<tr>
<td><?php print($row['FteName']); ?></td>
<td><?php print($row['ProdMgr']); ?></td>
<td><?php print($row['CustName']); ?></td>
<td><?php print($row['CustPoNum']); ?></td>
<td><?php print($row['CustPoDate']); ?></td>
<td align="center">
<i class="glyphicon glyphicon-edit"></i>
</td>
<td align="center">
<i class="glyphicon glyphicon-remove-circle"></i>
</td>
</tr>
<?php
}
}
else
{
?>
<tr>
<td>Nothing here...</td>
</tr>
<?php
}
}
public function paging($query,$records_per_page)
{
$starting_position=0;
if(isset($_GET["page_no"]))
{
$starting_position=($_GET["page_no"]-1)*$records_per_page;
}
$query2=$query." limit $starting_position,$records_per_page";
return $query2;
}
public function paginglink($query,$records_per_page)
{
$self = $_SERVER['PHP_SELF'];
$stmt = $this->db->prepare($query);
$stmt->execute();
$total_no_of_records = $stmt->rowCount();
if($total_no_of_records > 0)
{
?><ul class="pagination"><?php
$total_no_of_pages=ceil($total_no_of_records/$records_per_page);
$current_page=1;
if(isset($_GET["page_no"]))
{
$current_page=$_GET["page_no"];
}
if($current_page!=1)
{
$previous =$current_page-1;
echo "<li><a href='".$self."?page_no=1'>First</a></li>";
echo "<li><a href='".$self."?page_no=".$previous."'>Previous</a></li>";
}
for($i=1;$i<=$total_no_of_pages;$i++)
{
if($i==$current_page)
{
echo "<li><a href='".$self."?page_no=".$i."' style='color:red;'>".$i."</a></li>";
}
else
{
echo "<li><a href='".$self."?page_no=".$i."'>".$i."</a></li>";
}
}
if($current_page!=$total_no_of_pages)
{
$next=$current_page+1;
echo "<li><a href='".$self."?page_no=".$next."'>Next</a></li>";
echo "<li><a href='".$self."?page_no=".$total_no_of_pages."'>Last</a></li>";
}
?></ul><?php
}
}
/* paging */
}
Your CRUD class is OK.
You are not sending all 15 parameters to create() method.
Update
if($crud->create($FteName=$SalesMgr=$GEO=$ProdMgr=$AeName=$CustName=$CustCat=$CustPoNum=$CustPoDate=$SalesQrt=$PaymentStat=$SONum=$AmtPaid=$DatePaid=$OppoGold=$CheckBy))
To:
if($crud->create($FteName, $SalesMgr, $GEO, $ProdMgr, $AeName, $CustName, $CustCat, $CustPoNum,
$CustPoDate, $SalesQrt, $PaymentStat, $SONum, $AmtPaid, $DatePaid, $OppoGold, $CheckBy))
Replace = by ,. By adding = after every parameter, you are sending assignment operator.
And only last value as a single parameter is being sent whereas 15 parameters are required.
<table class="table table-bordered">
<thead>
<tr>
<th class="col-md-2">First Name</th>
<th class="col-md-2">Last Name</th>
<th class="col-md-2">Present</th>
<th class="col-md-2">Absent</th>
</tr>
</thead>
<?php foreach($teacher_names as $name): ?>
<tbody>
<tr>
<td class="col-md-2"><input class="form-control" type="text" readonly="readonly" name="f_name" value="<?php echo $name['first_name']; ?>"></td>
<td class="col-md-2"><input class="form-control" type="text" readonly="readonly" name="l_name" value="<?php echo $name['last_name']; ?>"></td>
<td class="col-md-2"><input type="checkbox" name="present" value="Y"></td>
<td class="col-md-2"><input type="checkbox" name="absent" value="N"></td>
</tr>
</tbody>
<?php endforeach;?>
</table>
I want to be able to access all values in my database which at the moment is 10. I want to get all the $_POST values and then insert them into the database but it seems i only get the one POST value in the foreach loop which is the last key value. An example of the php script is
public function teachers_attendance($first_name, $last_name, $present, $absent){
$sql = "INSERT INTO teacher_attendance($first_name, $last_name, $present, $absent)
VALUES(:first_name, :last_name, :present, :absent)";
$stmt = $this->_connection->prepare($sql);
$stmt->bindValue(':first_name', $first_name, PDO::PARAM_INT);
$stmt->bindValue(':last_name', $last_name, PDO::PARAM_STR);
$stmt->bindValue(':present', $present, PDO::PARAM_STR);
$stmt->bindValue(':absent', $absent, PDO::PARAM_STR);
$stmt->Execute();
$num_rows = $stmt->rowCount();
if($num_rows > 0){
echo "Yes";
}else{
echo "No";
}
}
I just would want to be able to access all the POST value and checkbox values into an array and then insert them all in the database. I would be grateful if i can have some solutions to this problem.
Since it didn't click with me the first time about un-matching keys when checkboxes are not selected, I've written up another method of accomplishing what you're after.
So your template should be as follows:
<table class="table table-bordered">
<thead>
<tr>
<th class="col-md-2">First Name</th>
<th class="col-md-2">Last Name</th>
<th class="col-md-2">Present</th>
<th class="col-md-2">Absent</th>
</tr>
</thead>
<tbody>
<?php
$i = 0;
foreach($teacher_names as $name):
?>
<tr>
<td class="col-md-2"><input class="form-control" type="text" readonly="readonly" name="f_name_<?php echo $i; ?>" value="<?php echo $name['first_name']; ?>" /></td>
<td class="col-md-2"><input class="form-control" type="text" readonly="readonly" name="l_name_<?php echo $i; ?>" value="<?php echo $name['last_name']; ?>" /></td>
<td class="col-md-2"><input type="checkbox" name="present_<?php echo $i; ?>" value="Y" /></td>
<td class="col-md-2"><input type="checkbox" name="absent_<?php echo $i; ?>" value="N" /></td>
</tr>
<?php
$i++;
endforeach;
?>
</tbody>
</table>
Then you start at 0, add 1 each time, and loop until numbered name fields are no longer found (at which point it is assumed there are no more entries)
<?php
// First row to check is 0, as per template
$i = 0;
// Loop while f_name_* and l_name_* are found (if not found, it is assumed there are no more rows)
while( isset( $_POST['f_name_'.$i] ) && isset( $_POST['l_name_'.$i] ) )
{
// Get and set name variables (based on current row)
$first_name = $_POST['f_name_'.$i];
$last_name = $_POST['l_name_'.$i];
// Presence and absence are checkboxes with a Y value, so we'll set these to 'N' if not found
$present = ( isset( $_POST['present_'.$i] ) ? $_POST['present_'.$i] : 'N' );
$absent = ( isset( $_POST['absent_'.$i] ) ? $_POST['absent_'.$i] : 'N' );
// Call the teachers_attendance function
teachers_attendance($first_name, $last_name, $present, $absent);
// Increment the row to check
$i++;
}
?>
I am using the joomla framework to return values from a POST request, and the print screen shows me data, but when using the array in sending me to a method and print or send me data.
Here I put the code that I've got gray hair,thanks in advance.
This is the controller:
/**
* Construct (registers additional tasks to methods).
*/
function __construct(){
parent::__construct();
//Registro de tareas extra
$this->registerTask('add','ingresarPlanilla');
}//function
function ingresarPlanilla(){
// Comprueba del request la clave de falsificación
//JRequest::checkToken('post') or die( 'Objeto invalido' );
$task = JRequest::getVar('task');
$model = &$this->getModel('planilla');
if ($returnid = $model->ingresar()) {
switch ($task) {
case 'add' :
$link = '?option=com_mercurio&view=planilla&controller=planilla&task=add';
break;
default :
$link = 'index.php?option=com_mercurio&view=planilla';
break;
}
$msg = JText::_( 'PLANILLA INGRESADA' );
$cache = &JFactory::getCache('com_mercurio');
$cache->clean();
} else {
$msg = 'PLANILLA NO INGRESADA';
$link = 'index.php?option=com_mercurio&view=planilla';
}
//$model->checkin();
$this->setRedirect($link, $msg);
}
}
This is the model:
$cliente = new SoapClient(URLMERCURIOWS.URLWSPLANILLA, array('login'=>LOGINWS,'password'=>PASSWORDWS));
if (is_soap_fault($cliente)) {
trigger_error("SOAP Fault: (faultcode: {$arr->faultcode}, faultstring: {$arr->faultstring})", E_USER_ERROR);
return false;
}
$postost = JRequest::get( 'post', JREQUEST_ALLOWHTML );
$postost['cdPoblacionOrigen'] = JRequest::getVar('cdPoblacionOrigen', '', 'post', 'cdPoblacionOrigen');
$postost['nmSecDniCliente'] = JRequest::getVar('nmSecDniCliente', '', 'post', 'nmSecDniCliente');
$postost['cdAgenciaCliente'] = JRequest::getVar('cdAgenciaCliente', '', 'post', 'cdAgenciaCliente');
$postost['nmPesoTransportado'] = JRequest::getVar('nmPesoTransportado', '', 'post', 'nmPesoTransportado');
$postost['nmVolumenTransportado'] = JRequest::getVar('nmVolumenTransportado', '', 'post', 'nmVolumenTransportado');
$postost['nmUndsTransportadas'] = JRequest::getVar('nmUndsTransportadas', '', 'post', 'nmUndsTransportadas');
$planilla = array();
$planilla = $postost;
echo $postost['cdPoblacionOrigen']."</br>";
echo $postost['nmSecDniCliente']."</br>";
echo $postost['cdAgenciaCliente']."</br>";
echo $postost['nmPesoTransportado']."</br>";
echo $postost['nmVolumenTransportado']."</br>";
echo $postost['nmUndsTransportadas']."</br>";
$cliente->ingresarPlanilla( AGENCIAXDEFECTO, null, null, null, $postost['cdPoblacionOrigen'], $post['nmSecDniCliente'], $post['cdAgenciaCliente'], null, $post['nmPesoTransportado'], $post['nmVolumenTransportado'], $post['nmUndsTransportadas'], null, null, null, null, null, null, null, null, null);
return true;
}
This is the view:
<form id="ingresarPlanilla" name="ingresarPlanilla" method="post" action="?option=com_mercurio&view=planilla&controller=planilla&task=add">
<table width="98%" border="1" bordercolor="#ECE9D8">
<tr>
<td width="21%" class="titulo" align="center">Ingresar Planilla</td>
<td width="29%"> </td>
<td width="21%"> </td>
<td width="29%"> </td>
</tr>
<tr>
<td colspan="2">Agencia Origen</td>
<td colspan="2"><input name="cdAgenciaOrigen" type="text" class="campo_noeditable" id="cdAgenciaOrigen" value="<?php echo AGENCIAXDEFECTO;?>"readonly="readonly"/></td>
</tr>
<tr>
<td colspan="2">Poblacion Origen</td>
<td colsp man="2"><input name="cdPoblacionOrigen" type="text" class="campo" id="cdPoblacionOrigen" /></td>
</tr>
<tr>
<td colspan="2">DNI Cliente</td>
<td colspan="2"><input name="nmSecDniCliente" value="<?php echo $aux[5];?>" type="text" class="campo" id="nmSecDniCliente"/></td>
</tr>
<tr>
<td colspan="2">Peso Transportado</td>
<td colspan="2"><input name="nmPesoTransportado" type="text" class="campo" id="nmPesoTransportado "/></td>
</tr>
<tr>
<td colspan="2">Volumnen Transportado</td>
<td colspan="2"><input name="nmVolumenTransportado" type="text" class="campo" id="nmVolumenTransportado"/></td>
</tr>
<tr>
<td colspan="2">Unidades Transportados</td>
<td colspan="2"><input name="nmUndsTransportadas" type="text" class="campo" id="nmUndsTransportadas"/></td>
</tr>
<tr>
<td colspan="3">Observaciones</td>
</tr>
<tr>
<td colspan="3"><textarea name="observaciones" cols="60" rows="3" class="campo" id="observaciones"></textarea></td>
</tr>
<tr>
<td class="label"><input type="submit" name="Enviar" id="Enviar" value="Enviar" /></td>
</tr>
<input type="hidden" name="option" value="com_mercurio" />
<input type="hidden" name="cdAgenciaCliente" value="<?php echo $aux[6];?>" />
<input type="hidden" name="view" value="<?php echo JRequest::getVar('view'); ?>" />
<input type="hidden" name="task" value="" />
<?php echo JHTML::_( 'form.token' ); ?>
You can use this line below to read all POST data into an array with key value pairs.
$post = JRequest::get('post');
This will load all values into an array. So you would use the above like so:
$post = JRequest::get('post');
echo $post['cdPoblacionOrigen']; // prints value of post for input with name 'cdPoblacionOrigen'