PHP从不同页面

时间:2017-04-03 18:06:02

标签: php html

所以这不是从一个页面到另一个页面的典型获取帖子。

基本上我的网站上有一个密码重置功能,所以用户将在一个页面上输入他们的电子邮件地址,他们会收到一封带有重置链接的电子邮件,该链接在其末尾有一个令牌,当他们打开该链接时,它只是要求他们提供新密码并确认新密码和提交,这就完全不会在此页面上使用/引用电子邮件。它的初始目的很好但现在我正在将XML服务端点集成到此中,因此当客户在新密码屏幕上重置密码时,它也会在XML服务端点上更新其密码,但要求他们的电子邮件登录到该帐户是为了更新我无法工作的密码。

我尝试了_Session和_Post和_Get但似乎没有任何效果,因为它与“电子邮件”页面的会话不完全相同,而不是“新密码”,“确认新密码”页面。

这两个后端页面,在控制器中的forgotten.php,它基本上只引用了预定义语言的ex。 (entry_email引用另一个php文件,该文件为$ entry_email =“请输入您的电子邮件地址:”

然后是另一个模型页面,它指向并对MySQL DB进行更新/更改/查询。

请求电邮页面:

<?php echo $header; ?>
<div id="content">
    <?php if ($error_warning) { ?>
    <div class="warning"><?php echo $error_warning; ?></div>
    <?php } ?>
  <div class="content-title">
    <h1><?php echo $content_title; ?></h1>
  </div>
  <form action="index.php?route=account/forgotten" method="post" enctype="multipart/form-data">
    <center><p><?php echo $text_email; ?></p></center>
    <div class="content">
    <h2><?php echo $text_your_email; ?></h2>
      <table class="form">
        <tr>
          <td><?php echo $entry_email; ?></td>
          <td><input type="text" name="email" value="<?php echo $email; ?>" /></td>
        </tr>
      </table>
        <div class="page_buttons">
          <a href="<?php echo $back; ?>" class="button b_left"><?php echo $button_back; ?></a>
          <input type="submit" value="<?php echo $button_submit; ?>" class="button b_right" />
        </div>
    </div>
  </form>
  <?php echo $content_bottom; ?></div>
  <div id="placeholder"></div>
<?php echo $footer; ?>

输入新密码和确认页面:

<div id="content">
    <?php if ($error_warning) { ?>
        <div class="warning"><?php echo $error_warning; ?></div>
    <?php } else { ?>
      <div class="content-title">
        <h1><?php echo $reset_content_title; ?></h1>
      </div>
      <form action="index.php?route=account/forgotten/reset" method="post" enctype="multipart/form-data">
        <div class="content">
        <h2><?php echo $reset_content_title; ?></h2>
          <table class="form">
            <tr>
              <td><?php echo $entry_password; ?></td>
              <td><input type="password" name="password" value="" />
                <?php if ($error_password) { ?>
                <span class="error"><?php echo $error_password; ?></span>
                <?php } ?></td><input type="hidden" name="token" value="<?php echo $_GET['token'];?>" />
            </tr>
            <tr>
              <td><?php echo $entry_confirm; ?></td>
              <td><input type="password" name="confirm" value="" />
                <?php if ($error_confirm) { ?>
                <span class="error"><?php echo $error_confirm; ?></span>
                <?php } ?></td>
            </tr>
          </table>
          <div class="page_buttons">
            <input type="submit" value="<?php echo $button_reset; ?>" class="button b_right" />
          </div>
        </div>
      </form>
    <?php } ?>
  <?php echo $content_bottom; ?></div>
  <div id="placeholder"></div>
<?php echo $footer; ?>

提交时的MySQL查询:

    public function editPasswordByToken($token, $password) {
    $this->db->query("UPDATE " . DB_PREFIX . "customer SET cus_code ='',                        cus_password = '" . $this->db->escape(sha1($password)) . "' WHERE cus_code = '" . $this->db->escape($token) . "' LIMIT 1 ");
}
    public function getCustomerByToken($token) {
    $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "customer WHERE cus_code = '" . $this->db->escape($token) . "' LIMIT 1 ");

    return $query->row;
}

Public Function Reset()代码:

        if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->resetvalidate()) {

        $this->submitMiva();  

        $this->model_account_customer->editPasswordByToken($this->request->post['token'], $this->request->post['password']); 

        $this->session->data['success'] = $this->language->get('text_reset_success');

        //$this->redirect($this->url->link('account/login', '', 'SSL'));
    }

0 个答案:

没有答案