PHP解决方案:我有一个用post获得的页面,但需要延迟一些代码,直到页面发布为止-codeigniter


PHP solution: I have a page that I get with post but need to delay some code until the page has posted - codeigniter

我知道标题很令人困惑,但我不知道如何简要描述它:基本上,我有一个从按钮获得的网页,当按下按钮时,某些数据(一个唯一的标识名)会被提交到我想要查看的页面,页面也会被查看,但因为从技术上讲,它总是request_method=post,所以当我在表单上提交我想要查看页面的数据时,我希望UID保持不变,但它不会,因为它会被刷新,如果我不清楚,不要标记帖子,要聪明,询问你需要的更多信息。

这是相关代码:

我的控制器:

public function clist() {
        $this->load->model('list_model');
        $fields = $this->list_model->listcliname();
        $data = array();
        $data['fields'] = $fields;
        $this->load->view('clientlist', $data);
    }
    public function clistedit() {
        $uid = $_POST['UID'];
        $data2 = array();
        $data2['uid'] = $uid;
        $this->load->view('clientlistedit', $data2);
        if ($this->input->server('REQUEST_METHOD') == 'POST') {
            $client = array (
            'UID' => $uid,
            'name' => $_POST['name'],
            'address' => $_POST['address'],
            'telephone' => $_POST['telephone'],
            'fax' => $_POST['fax'],
            'email' => $_POST['email'],
            'mobile' => $_POST['mobile'],
            'contact' => $_POST['contact']
            );
            $this->load->model('list_model');
            $this->list_model->editcli($client);
        }
        else {
        $this->load->model('list_model');
        }
    }

我发布原始数据的视图:

        <form action="clistedit" method="post">
        <button name="UID" type="submit" value="<?php echo $field['UID']?>">edit</button>
         </li>
         </ul>
         <?php
    }

?>

我的观点是,当我收集下一组数据时,页面会转到:

<html>
    <body>
    <?php
    ?>
     <form action="/clientlist/clistedit" method="post">
name: <input type="text" name="name" value="<?php ?>"><br>
Contact: <input type="text" name="contact" value="<?php ?>"><br>
Address: <input type="text" name="address" value="<?php ?>"><br>
Telephone: <input type="text" name="telephone" value="<?php ?>"><br>
Fax: <input type="text" name="fax" value="<?php ?>"><br>
E-mail: <input type="text" name="email" value="<?php ?>"><br>
Mobile: <input type="text" name="mobile" value="<?php ?>"><br>
 <input type="submit" value="<?php return $uid;?>">
</form>
<?php

有人能解决我的问题吗?感谢

<input type="submit" value="<?php return $uid;?>">更改为

<input type="submit" name="UID" value="<?php echo $uid;?>">

你应该没事的。

但是,由于你不希望提交按钮显示为带有数字的按钮,你最好这样做:

<input type="hidden" name="UID" value="<?php echo $uid; ?>" /> 
<input type="submit" value="Whatever you prefer it to say" /> 

这将实现相同的结果,而不必改变任何其他内容。

干杯!