Php 如何从foreach循环中分离单个post值
我正在构建一个应用程序,其中我有一个带有多个文件上传的表单 当用户提交表单时,foreach循环捕获的所有post值如下Php 如何从foreach循环中分离单个post值,php,html,codeigniter,Php,Html,Codeigniter,我正在构建一个应用程序,其中我有一个带有多个文件上传的表单 当用户提交表单时,foreach循环捕获的所有post值如下 if($booker->setsessions($_POST)) { $this->redirect(array('controller'=>'homes','action'=>'step_four')); } else { $this->setFlashMsg('Please Provide Valid Information','me
if($booker->setsessions($_POST))
{
$this->redirect(array('controller'=>'homes','action'=>'step_four'));
}
else
{
$this->setFlashMsg('Please Provide Valid Information','message-box ok');
}
这里是捕捉post值
foreach($data as $index=>$value){
$this->$index=$value;
}
$this->save();
$booking->booker_id =$this->id;
$booking->save();
public function save()
{
if (!$this->id) {
$this->create();
}
else {
$this->update();
}
}
protected function create()
{
$connection = db::factory('mysql');
$sql = "insert into {$this->table} (`";
$sql .= implode('`, `', array_keys($this->values));
$sql .= "`) values ('";
$clean = array();
foreach ($this->values as $value) {
$clean[] = $connection->clean($value);
}
$sql .= implode("', '", $clean);
$sql .= "')";
$this->id = $connection->insertGetID($sql);
}
这里$this->save();获取所有$index=>值并插入到一个表中
我的表格是这样的
<form class="form-3 form-horizontal ajxfrm" id="step-three" enctype="multipart/form-data" action="<?php echo $html->addLink(array('controller'=>'homes','action'=>'step_three_ajax')); ?>" method="post">
<input id="name" type="text" name="name" />
<input id="email" type="text" name="email" />
<input id="city" type="text" name="city" />
<input id="contact" type="text" name="contact" />
<input id="fileupload" type="file" name="fileupload[]" />
您的问题不清楚,您应该使用$\u FILE
而不是$\u POST
来访问您的文件。我正在更新问题,所以我给您答对了,您获取所有的$\u POST
值并将其指定为属性,并且您希望对文件使用表a
,对提交的任何其他信息使用表b
?还添加了如何插入Dianuj:-更新了问题