接下来运行PHP脚本?

时间:2014-03-28 16:32:47

标签: php mysql forms

我有2个PHP动作脚本(action_myquiz)和(action_sendemailquiz),第一个脚本链接到一个表单,该表单从用户捕获数据并将其存储在我的数据库的表中。

我的第二个脚本从上表中选择最后输入的记录并将其发送到外部电子邮件营销组。

问题是如何在第一个脚本执行后直接运行第二个脚本?目前我只是粘贴第二个的URL并手动运行它以进行测试,但现在我需要自动化它。这需要一个cron工作还是有其他方法可以做到这一点?

脚本1

public function action_myquiz() {
    $this->template->styles['assets/css/myquiz.css'] = 'screen';
    $this->template->jscripts[] = 'assets/scripts/myquiz.js';
    $this->template->content = View::factory('quiz/myquiz');
        $this->template->content->thanks = false;
        if ($this->request->post('entry')) {
            $post = $this->request->post('entry');

            // save participant's info
            $stmt = DB::query(Database::INSERT, 'INSERT INTO `myquiz` (`support_you`, `mattress_collections`, `what_game`, `first_name`, `last_name`, `email`, `confirm_email`, `phone`, `postcode`)
                                                                        VALUES (:support_you, :mattress_collections, :what_game, :first_name, :last_name, :email, :confirm_email, :phone, :postcode)');                                                     

            $stmt->param(':support_you', $post['support_you']);
            $stmt->param(':mattress_collections', $post['mattress_collections']);
            $stmt->param(':what_game', $post['what_game']);
            $stmt->param(':first_name', $post['first_name']);
            $stmt->param(':last_name', $post['last_name']);
            $stmt->param(':email', $post['email']);
            $stmt->param(':confirm_email', $post['confirm_email']);
            $stmt->param(':phone', $post['phone']);
            $stmt->param(':postcode', $post['postcode']);
            try {
                $stmt->execute();
            //  var_dump($post);
            } catch (Exception $e) {
                FB::error($e);
            }

            $this->template->content->thanks = true;
        }
    }

脚本2

public function action_sendemailquiz(){

    $results = DB::select('first_name', 'last_name', 'email', 'postcode')->from('myquiz')->order_by('id', 'DESC')->limit(1)->execute();
    $users = $results->as_array();
     foreach($users as $user)
    {
     echo 'First Name: '.$user['first_name'];
     echo 'Last Name: '.$user['last_name'];
     echo 'Email: '.$user['email'];
     echo 'Postcode: '.$user['postcode'];
    }
            .................rest of my code

0 个答案:

没有答案