Welcome Guest, Not a member yet? Register   Sign In
input post problem [SOLVED]
#1

[eluser]Hamed[/eluser]
Hello,
I code a view and a controller but in controller I can not use input:
controller code:
Code:
<?php if (!defined('BASEPATH'))
    exit('No direct script access allowed');

/**
* @author Ali Ghasemzadeh
* @copyright 2012
*/

class Amass extends CI_Controller
{
    public function __construct()
    {
        parent::__construct();
        if ($this->session->userdata('isAdmin') != 1) {
            die("Forbbiden!");
        }
    }
    public function lists()
    {
        $queryuser = $this->db->query("SELECT * FROM `user`");
        $data['users'] = $queryuser->result();
        $this->load->view('admin/auser_lists_mass', $data);
    }
    public function sendMass()
    {
        $type = $this->input->post('type');
        $all = $this->input->post('all');
        $queryuser = $this->db->query("SELECT * FROM `user`");
        $numuser = $queryuser->num_rows();
        $emails = array();
        $mobs = array();
        if ($all == 'yes') {
            if ($type == 'email') {
                $users = $queryuser->result();
                $n = 1;
                foreach ($users as $user) {
                    $emails[$n] = $user->email;
                    $n++;
                }
            } else {
                $users = $queryuser->result();
                $n = 1;
                foreach ($users as $user) {
                    $mobs[$n] = $user->mobile;
                    $n++;
                }
            }
        } else {
            if ($type == 'email') {
                $users = $queryuser->result();
                $n = 1;
                foreach ($users as $user) {
                    if ($this->input->post('id_' . $user->uid)) {
                        $emails[$n] = $user->email;
                        $n++;
                    }
                }
            } else {
                $users = $queryuser->result();
                $n = 1;
                foreach ($users as $user) {
                    if ($this->input->post('id_' . $user->uid)) {
                        $mobs[$n] = $user->mobile;
                        $n++;
                    }
                }
            }
        }
        print_r($emails);
        print_r($mobs);
        $data['msg'] = "پیامک ارسال شد".$all.$type;
        $data['url'] = base_url() . "index.php/amass/lists";
        $this->load->view('main/redirect', $data);
    }

}

?>
view code:
Code:
<html>
<?php
$this->load->view('main/header');
?>
<body>
<?php
$this->load->view('main/bar');
?>
<div align="center">
<div class="header"></div>
        &lt;?php
        $this->load->view('main/menu');
        ?&gt;
    <div class="prlist">
     <div class="livesupport">
         <a href="ymsgr:sendim?epaymer20"><img src="&lt;?php echo  base_url(); ?&gt;resource/img/livesupport.png"/></a>
        </div>
    </div>
    <div class="page">
    &lt;?php
    $this->load->view("main/sidebar");
    ?&gt;
    <div class="products">
   <div class="paget"></div>
            <div class="pagem">
             <div class="ptext">
                &lt;form action="&lt;?php echo  base_url(); ?&gt;index.php/amass/sendMass"&gt;
                    <table cellpadding="0" cellspacing="0" border="0" class="display" id="dateTableJS">
                    
        <thead>
        <tr>
        <th>#</th>
              <th>&lt;input type="checkbox" id="selectAll" /&gt;&lt;/th>
        <th>نام</th>
        <th>نام کاربری</th>
                 <th>ایمیل</th>
        <th>شماره تماس</th>
        </tr>
        </thead>
                &lt;?php
                $n = 1;
                foreach($users as $user){
                    ?&gt;
                      <tr class="gradeA">
                            <td>&lt;?php echo $user->uid; ?&gt;</td>
                            <td>&lt;input type="checkbox" id="selector" name="id_&lt;?php echo $user-&gt;uid; ?&gt;" value="&lt;?php echo $user-&gt;email; ?&gt;:&lt;?php echo $user-&gt;mobile; ?&gt;" /&gt;&lt;/td>
                    <td>&lt;?php echo $user->name; ?&gt;</td>
                            <td>&lt;?php echo $user->username; ?&gt;</td>
   <td>&lt;?php echo $user->email; ?&gt;</td>
            <td>&lt;?php echo $user->mobile; ?&gt;</td>
  </tr>
                    &lt;?php
                    $n++;
                }
                ?&gt;
                    </table>
                    پیام:&lt;textarea name="message" cols="70" rows="7"&gt;&lt;/textarea>
                    <br />
                    نوع ارسال گروهی: <select name="type"><option value="email">Email</option><option value="sms">SMS</option></select>
                    <br />
                    ارسال همگانی: <select name="all"><option value="yes">بله</option><option value="no">خیر</option></select>
                    <br />
                    ارسال همگانی برای تمامی مشتری ها بدون توجه به انتخاب ها صورت می گیرد
                    
                    <br />
                    &lt;input type="submit" value="ارسال" /&gt;&lt;input type="reset" value="تنظیم مجدد" />
                    &lt;/form&gt;
                    
                </div>
            </div>
            <div class="pageb"></div>
        </div>
    </div>
&lt;?php
$this->load->view('main/news');
?&gt;
    <div class="copyright">
     <div class="logos">
         <img src="&lt;?php echo  base_url(); ?&gt;resource/img/logoft.png"/>
        </div>
    </div>
</div>
&lt;/body&gt;
&lt;/html&gt;

I really don't know my problem. please help me to solve this problem.
$type = $this->input->post('type');
$all = $this->input->post('all');
doesn't work for me.

method="post" in form tag.
#2

[eluser]TWP Marketing[/eluser]
I see that you've marked this thread as SOLVED, but it might help future users to know how it was solved.
Your last comment says that the form method is set to 'post', however the code does not have a method parameter set in form_open(). Was that the solution?
#3

[eluser]Hamed[/eluser]
I forgot method="post" in form tag and default method is get.




Theme © iAndrew 2016 - Forum software by © MyBB