CodeIgniter $ this- & gt; input-> get_post () пусто Представления для контроллера

Это мой код:

Просмотры :

<form method="post" action="<?php echo base_url(); ?>index.php/rbts/get_songs">
<div class="form-group">
<!-------------------------------------------------------- TOP Songs-------------------------------------------------------------->
<label class="col-sm-2 control-label">Top 1</label>
<div class="col-sm-10">
<select name="drptop_1" id="drptop_1" class="form-control m-b">
<?php
$n = 1;
foreach($songs as $song){
if($song['id']==$n){
?>
<option value="<?php echo $song['rbt_id']; ?>" selected><?php echo $song['title']; ?></option>
<?php
}
else if($song['id']==null){
?>
<option value="<?php echo $song['rbt_id']; ?>"><?php echo "--------" ?></option>
<?php
}
else{
?>
<option value="<?php echo $song['rbt_id']; ?>"><?php echo $song['title']; ?></option>
<?php
}
}
?>
</select>

</div>
<br><br>
<label class="col-sm-2 control-label">Top 2</label>
<div class="col-sm-10">
<select name="drptop_2" id="drptop_2" class="form-control m-b">
<?php
$n = 2;
foreach($songs as $song){
if($song['id']==$n){
?>
<option value="<?php echo $song['rbt_id']; ?>" selected><?php echo $song['title']; ?></option>
<?php
}
else if($song['id']==null){
?>
<option value="<?php echo $song['rbt_id']; ?>"><?php echo "--------" ?></option>
<?php
}
else{
?>
<option value="<?php echo $song['rbt_id']; ?>"><?php echo $song['title']; ?></option>
<?php
}
}
?>
</select>
</div> <br><br>
<label class="col-sm-2 control-label">Top 3</label>
<div class="col-sm-10">
<select name="drptop_3" id="drptop_3" class="form-control m-b">
<?php
$n = 3;
foreach($songs as $song){
if($song['id']==$n){
?>
<option value="<?php echo $song['rbt_id']; ?>" selected><?php echo $song['title']; ?></option>
<?php
}
else if($song['id']==null){
?>
<option value="<?php echo $song['rbt_id']; ?>"><?php echo "--------" ?></option>
<?php
}
else{
?>
<option value="<?php echo $song['rbt_id']; ?>"><?php echo $song['title']; ?></option>
<?php
}
}
?>
</select>
</div> <br><br>
<label class="col-sm-2 control-label">Top 4</label>
<div class="col-sm-10">
<select name="drptop_4" id="drptop_4" class="form-control m-b">
<?php
$n = 4;
foreach($songs as $song){
if($song['id']==$n){
?>
<option value="<?php echo $song['rbt_id']; ?>" selected><?php echo $song['title']; ?></option>
<?php
}
else if($song['id']==null){
?>
<option value="<?php echo $song['rbt_id']; ?>"><?php echo "--------" ?></option>
<?php
}
else{
?>
<option value="<?php echo $song['rbt_id']; ?>"><?php echo $song['title']; ?></option>
<?php
}
}
?>
</select>
</div> <br><br>
<label class="col-sm-2 control-label">Top 5</label>
<div class="col-sm-10">
<select name="drptop_5" id="drptop_5" class="form-control m-b">
<?php
$n = 5;
foreach($songs as $song){
if($song['id']==$n){
?>
<option value="<?php echo $song['rbt_id']; ?>" selected><?php echo $song['title']; ?></option>
<?php
}
else if($song['id']==null){
?>
<option value="<?php echo $song['rbt_id']; ?>"><?php echo "--------" ?></option>
<?php
}
else{
?>
<option value="<?php echo $song['rbt_id']; ?>"><?php echo $song['title']; ?></option>
<?php
}
}
?>
</select>
</div>
<br><br>
<!-------------------------------------------------------- New Songs-------------------------------------------------------------->
<hr height="5px" width="100%">
<label class="col-sm-2 control-label">New 1</label>
<div class="col-sm-10">
<select name="drptop_6" id="drptop_6" class="form-control m-b">
<?php
$n = 6;
foreach($songs as $song){
if($song['id']==$n){
?>
<option value="<?php echo $song['rbt_id']; ?>" selected><?php echo $song['title']; ?></option>
<?php
}
else if($song['id']==null){
?>
<option value="<?php echo $song['rbt_id']; ?>"><?php echo "--------" ?></option>
<?php
}
else{
?>
<option value="<?php echo $song['rbt_id']; ?>"><?php echo $song['title']; ?></option>
<?php
}
}
?>
</select>
</div> <br><br>
<label class="col-sm-2 control-label">New 2</label>
<div class="col-sm-10">
<select name="drptop_7" id="drptop_7" class="form-control m-b">
<?php
$n = 7;
foreach($songs as $song){
if($song['id']==$n){
?>
<option value="<?php echo $song['rbt_id']; ?>" selected><?php echo $song['title']; ?></option>
<?php
}
else if($song['id']==null){
?>
<option value="<?php echo $song['rbt_id']; ?>"><?php echo "--------" ?></option>
<?php
}
else{
?>
<option value="<?php echo $song['rbt_id']; ?>"><?php echo $song['title']; ?></option>
<?php
}
}
?>
</select>
</div> <br><br>
<label class="col-sm-2 control-label">New 3</label>
<div class="col-sm-10">
<select name="drptop_8" id="drptop_8" class="form-control m-b">
<?php
$n = 8;
foreach($songs as $song){
if($song['id']==$n){
?>
<option value="<?php echo $song['rbt_id']; ?>" selected><?php echo $song['title']; ?></option>
<?php
}
else if($song['id']==null){
?>
<option value="<?php echo $song['rbt_id']; ?>"><?php echo "--------" ?></option>
<?php
}
else{
?>
<option value="<?php echo $song['rbt_id']; ?>"><?php echo $song['title']; ?></option>
<?php
}
}
?>
</select>
</div> <br><br>
<label class="col-sm-2 control-label">New 4</label>
<div class="col-sm-10">
<select name="drptop_9" id="drptop_9" class="form-control m-b">
<?php
$n = 9;
foreach($songs as $song){
if($song['id']==$n){
?>
<option value="<?php echo $song['rbt_id']; ?>" selected><?php echo $song['title']; ?></option>
<?php
}
else if($song['id']==null){
?>
<option value="<?php echo $song['rbt_id']; ?>"><?php echo "--------" ?></option>
<?php
}
else{
?>
<option value="<?php echo $song['rbt_id']; ?>"><?php echo $song['title']; ?></option>
<?php
}
}
?>
</select>
</div>
<br><br>
<label class="col-sm-2 control-label">New 5</label>
<div class="col-sm-10">
<select name="drptop_10" id="drptop_10" class="form-control m-b">
<?php
$n = 10;
foreach($songs as $song){
if($song['id']==$n){
?>
<option value="<?php echo $song['rbt_id']; ?>" selected><?php echo $song['title']; ?></option>
<?php
}
else if($song['id']==null){
?>
<option value="<?php echo $song['rbt_id']; ?>"><?php echo "--------" ?></option>
<?php
}
else{

?>
<option value="<?php echo $song['rbt_id']; ?>"><?php echo $song['title']; ?></option>
<?php
}

}?></select>
</div>
<br><br>
</div>
</div>

<div class="modal-footer">
<a href="<?php echo base_url(); ?>index.php/rbts/get_songs/" class="btn btn-default">Save</a>
<a href="#" class="btn btn-default" data-dismiss="modal">Close</a>
</div>
</form>

контроллеры:

public function get_songs(){$top1=$this->input->get_post('drptop1');
$top2=$this->input->get_post('drptop2');
$top3=$this->input->get_post('drptop3');
$top4=$this->input->get_post('drptop4');
$top5=$this->input->get_post('drptop5');
$new1=$this->input->get_post('drptop6');
$new2=$this->input->get_post('drptop7');
$new3=$this->input->get_post('drptop8');
$new4=$this->input->get_post('drptop9');
$new5=$this->input->get_post('drptop10');die(var_dump($top1));

//$this ->rbt->update_all_songs($top1,$top2,$top3,$top4,$top5,$new1,$new2,$new3,$new4,$new5);}

И после этого это всегда говорит bool(false). =.=

1

Решение

Вы получаете bool(false) потому что в $ top1 нет значения.

Во-вторых, имя ввода в форме отличается от имени переменной, которую вы используете для получения значения.

Example:
<select name="drptop_1" id="drptop_1" class="form-control m-b"></select>
AND
$top1=$this->input->get_post('drptop1');

Попробуйте, используя то же имя ввода name="drptop_1" и имя переменной php get_post('drptop1')
Надеюсь, это полезно.

0

Другие решения

Других решений пока нет …

По вопросам рекламы [email protected]